Skip to content
Articles
Article

Why your Flutter JSON model crashes at runtime (and how to generate one that doesn't)

by Chanpenh Yorn dev.to

3 min read

You write a model, the first API response parses fine, and a week later a crash report says: type 'int' is not a subtype of type 'double' in type cast Nothing in your code changed. The data did. Here are the three type errors I see most often with jsonDecode, why they happen, and how to write (or generate) models that survive real responses. 1. int vs double Dart's jsonDecode reads the number typ…

Forum

Questions about this, or something to add?

Discuss on the forum

Report this · Wrote this? Claim it

Supported by