Need some help regarding mapping data from Firestore to my model class in Flutter.
My database structure:
And my model class is below,
class Exercises {
String difficult, image, time, title;
List<dynamic> MainExercise = [];
Exercises.fromMap(Map<String, dynamic> data){
title = data['title'];
time = data['time'];
difficult = data['difficult'];
image = data['image'];
MainExercise = List<dynamic>.from(data['MainExercise']);
}
}
Error Thrown,
[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: The getter 'iterator' was called on null.
E/flutter (22059): Receiver: null
E/flutter (22059): Tried calling: iterator
E/flutter (22059): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
I want to read MainExercise array (along with other string fields) from Firestore and map it with my Exercises model class, which i will use to populate my list view.
