# Dart: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>' in type cast

**Code:** `type '_InternalLinkedHashMap' is not a subtype of type 'List<dynamic>'` · **Category:** Flutter / Dart · **Seen on:** Flutter

JSON decoded to a Map but your code expected a List (or the other way round).

## Meaning

`jsonDecode` returns a Map for `{…}` and a List for `[…]`. APIs often wrap lists in an object (`{"data": […]}`), or return an error object on failure. Print `response.body`, then read the right key before casting.

## Common causes

- Response is an object with a wrapper key, not a bare array
- Error JSON returned instead of the list
- Pagination envelope (`items`, `results`)
- Casting `as List` on a Map
- Mismatched model for single vs list endpoint

## Quick fix

1. Log `response.body` first
2. Read the wrapper key: `jsonDecode(body)['data'] as List`
3. Check `response.statusCode` before decoding

## Detailed fix by platform

### Dart

1. `final decoded = jsonDecode(body); final list = decoded is List ? decoded : decoded['items'] as List;`

## How to diagnose

1. **Body** — Object or array?
2. **Status** — 200?
3. **Key** — Wrapper name?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/flutter/type-map-not-subtype-of-list)
