Want to add List of Object to Firestore? To push an object to Firestore you need to convert your object to map, add this function to your class:
1 2 3 4 5 6 | Map<String, dynamic> toMap() { return { 'yourField1': yourValue1, 'yourField2': yourValue1, }; } |
To push a List of customSteps you need to convert all objects to map, you can do it with following method:
1 2 3 4 5 6 7 8 | static List<Map> ConvertCustomStepsToMap({List<CustomStep> customSteps}) { List<Map> steps = []; customSteps.forEach((CustomStep customStep) { Map step = customStep.toMap(); steps.add(step); }); return steps; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.