flutter json decode code example
Example 1: read json file flutter
Future<String>_loadFromAsset() async {
return await rootBundle.loadString("assets/quiz.json");
}
Future parseJson() async {
String jsonString = await _loadFromAsset();
final jsonResponse = jsonDecode(jsonString);
}
Example 2: flutter generate json files
flutter packages pub run build_runner build
Example 3: json decode list flutter
Iterable l = json.decode(response.body);
List<Post> posts = List<Post>.from(l.map((model)=> Post.fromJson(model)));