# Flutter: “type ‘List<dynamic>’ is not a subtype of type ‘List<int>’”

> type List<dynamic> is not a subtype of type List<int>: decoded JSON lists are List<dynamic>. Convert with List<int>.from, cast<int>(), or map each element.

Canonical: https://app369.com/fix/flutter-list-dynamic-is-not-a-subtype-of-list-int/
Last updated: 2026-11-08

Parsing JSON or reading Firestore data throws type ‘List<dynamic>’ is not a subtype of type ‘List<int>’ (or List<String>, List<Map<String, dynamic>>). jsonDecode and most data APIs build lists as List<dynamic>, even when every item is an int. Assigning that list to a List<int> variable, or using as List<int>, fails at runtime.

**Short answer**

Convert the list instead of casting it: List<int>.from(json['ids']) or (json['ids'] as List).cast<int>(). For lists of objects, map each element: (json['items'] as List).map((e) => Item.fromJson(e as Map<String, dynamic>)).toList().

## **Why the list has the wrong type, and the fix**

1. 01 ### **A JSON list assigned to a typed list**
  > “The elements iterable itself may have any element type, so this constructor can be used to down-cast a List” [**Dart, List.from constructor**](https://api.dart.dev/dart-core/List/List.from.html) final List<int> ids = json['ids']; compiles but fails at runtime. List.from creates a new list of the right type and checks every element.```
final ids = List<int>.from(json['ids'] as List);
final tags = List<String>.from(json['tags'] ?? const []);
```
2. 02 ### **A list of objects** Each element is a Map<String, dynamic>, so convert each one into your model with map and toList.```
final items = (json['items'] as List)
    .map((e) => Item.fromJson(e as Map<String, dynamic>))
    .toList();
```
3. 03 ### **cast<int>() and mixed numbers**
  > “If any operation tries to read an element that is not an instance of R, the access will throw instead.” [**Dart, List.cast**](https://api.dart.dev/dart-core/List/cast.html) cast<int>() returns a typed view without copying. It throws when an element isn’t an int, which happens when the API sends 1.0 or a string. Normalize those first: for 1.0, use (e as num).toInt(); for numeric strings, use int.parse(e as String).```
final counts = (json['counts'] as List).map((e) => (e as num).toInt()).toList();
```

Checked against the vendor’s docs on November 8, 2026: [Dart API: List.from](https://api.dart.dev/dart-core/List/List.from.html); [Dart API: List.cast](https://api.dart.dev/dart-core/List/cast.html); [Flutter: JSON and serialization](https://docs.flutter.dev/data-and-backend/serialization/json).

## **Rather hand it over?**

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

- [from $450**App Fix Ticket**One reproducible bug in an existing mobile or web app, diagnosed and fixed.**See scope and start**](https://app369.com/fixed-price/flutter-firebase-bug-fix/)
- [from $450**AI-Built App Rescue**A Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.****No issues worth fixing, no charge.**** If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.**See scope and start**](https://app369.com/fixed-price/ai-app-rescue/)

Related: [**Flutter “Map is not a subtype of type List”**](https://app369.com/fix/flutter-internallinkedhashmap-is-not-a-subtype-of-type-list/) · [**Flutter “type ‘Null’ is not a subtype of type ‘String’”**](https://app369.com/fix/flutter-type-null-is-not-a-subtype-of-type-string/) · [**Flutter “String can’t be assigned to Uri”**](https://app369.com/fix/flutter-string-cant-be-assigned-to-uri/) · [**Flutter “Looking up a deactivated widget’s ancestor is unsafe”**](https://app369.com/fix/flutter-looking-up-a-deactivated-widgets-ancestor-is-unsafe/)

Questions

## **More on this error**

<details>

<summary>**Should I use cast or List.from? **+</summary>

List.from copies and checks every element once, so errors show up where you parse. cast returns a view that checks on each read, so a bad element can fail later, far from the parsing code.

</details>

<details>

<summary>**Does json_serializable avoid this? **+</summary>

Yes. Generated fromJson code converts typed lists for you, which is why Flutter’s JSON guide recommends code generation for medium to large projects.

</details>

<details>

<summary>**Can you fix it for me? **+</summary>

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

</details>

A different error?

## **Describe it and get a written quote**

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.

[**Describe your problem **→](https://app369.com/contact/) [**All fixes**](https://app369.com/fix/)