I'm trying to add persistence to my app using firestore. It seems ace, but I've hit a bump in the road, and googling seems to be failing me. I think this may be more of a dart question than firestore, so please edit as you see fit!
Essentially I have a situation similar the following:
class attributes(){
double xpos, ypos;
String id;
}
class item(){
String name;
int price;
List<attributes> attributeHistory;
Map<String, dynamic> toMap(){
Map<String, dynamic> returnMap = new Map();
returnMap['name'] = name;
returnMap['price'] = price;
returnMap['attributeHistory'] = //what goes here??;
}
}
So... What goes there? I've written a .toMap function for attributes, but I don't know where that gets me!
Any ideas?
Create a List
of Map<String,dynamic>
returnMap['attributeHistory'] = attributeHistory.map((attribute) {
Map<String,dynamic> attributeMap = new Map<String,dynamic>();
attributeMap["id"] = attribute.id;
// same for xpos and ypos
return attributeMap;
}).toList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With