Skip to content
Articles
Article

Flutter JSON Parsing: fromJson, Null Safety and Code Generation

by Muhammad Naeem dev.to

11 min read

Almost every Flutter app talks to an API, and almost every API speaks JSON. Dart has no reflection in Flutter, so you can't hand a JSON string to a library and get a typed object back by magic. You either write the mapping yourself or generate it. This post covers both, in the order you'll meet them: jsonDecode, a hand-written model, the null safety traps, nested objects and lists, json_serializa…

Forum

Questions about this, or something to add?

Discuss on the forum

Report this · Wrote this? Claim it

FlutterX is supported by