In dart, i want to get a firestore document and that document has a field ‘products’ which is a list of maps, i want to save that list locally, edit it(user will edit using interface) then when the user is finished replace the original list with the updated one :
initDetails() async {
companyDetails() async {
var data = await FirebaseFirestore.instance
.collection("Plugs")
.doc(widget.useruid)
.get();
Map<String, dynamic> finalData = data.data()!;
return finalData;
}
await companyDetails().then((value) => setState(() {
companyData = value;
plugDocId = companyData.data.id;
editableInventory = companyData["products"];
companyName.text = companyData["name"];
companyLogo = companyData["logo"];
operation = companyData["o"];
fee = companyData["fee"];
}));
}
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
initDetails();
});
}
when i set the editiable inventory to late i get errors surrounding its initialization and when i set it to a empty list, the data is not showing up/updating, and it seems like no data is reaching the client.
Gas Musk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.