'How to create nested map from firestore data in flutter
I have this api i need to send data to that has a payload object that looks like
"members": [
{
"names": "ben",
"date-of-birth": "1978-01-01",
"gender": "Male",
"surname": "surname",
"role": "Partner",
"total-cut": "100.00"
}
],
basically I can put in a couple number of members in there like
"members": [
{
"names": "ben",
"date-of-birth": "1978-01-01",
"gender": "Male",
"surname": "surname",
"role": "Partner",
"total-cut": "100.00"
},
{
"names": "bennyy",
"date-of-birth": "1978-01-01",
"gender": "Male",
"surname": "surname",
"role": "Partner",
"total-cut": "80.00"
},
{
"names": "ben",
"date-of-birth": "1978-01-01",
"gender": "Male",
"surname": "surname",
"role": "Partner",
"total-cut": "100.00"
}
],
I have this data inside firestore in a collection as different documents. How can i iterate the response from firestore into this format. Currently what I am getting is a key-value format which this api does not follow clearly from the above sample this is my code, I create an empty map
final Map<String, dynamic> memberDetails = {};
then get the data from firestore and for each document i add it to the map I have created above
How can i solve this to get the format that i have up top
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
