Flutter-Tutorials icon indicating copy to clipboard operation
Flutter-Tutorials copied to clipboard

I want to add list of objects to firestore document

Open hkotabi opened this issue 5 years ago • 0 comments

Thank you for the great tutorial what if ingredients are objects not string I made ingredients data model and in the food data model I defined List<IngredientsModel> ingredients; FoodModel.fromMap(Map<String, dynamic> data){ id = data[ID]; name = data[NAME]; categories = data[CATEGORIES]; } Map<String, dynamic> toMap() { return { ID: id, NAME:name, CATEGORIES: categories,
}; }

I defined & filled a temporary list List<IngredientsModel> ingredientsTempList;

then I put values to food field food.ingredients = ingredientsTempList;

I found values in food.ingredients ex: print(food.ingredients[0].name)

when i save the product to firestore the screen hold, it doesn't save waiting for something?

hkotabi avatar Feb 24 '20 13:02 hkotabi