Hi I wanted to store a List into Firestore.
I am working on a project and in this page I will need to select some selection (selection is the DocumentID) and store it in a List, After that I need to retrieve from the List and call Firestore again to get the GeoPoint of the item based on the List (the List contains the DocumentID). Then I am able to retrieve that as well thanks to the help of the community. But now I can only store one of the Item of the List and not all of them.
This is my code:
void initRoute(data, dataInt) async{
Firestore.instance.collection('routes').document(inputName).setData({
dataInt:{
"Lat" : data['location'].latitude,
"Lng" : data['location'].longitude
}
});
}
I am able to store but it only store the first Item in the List into the Firestore. How can i store all of them into just 1 Document with few Map something similar to the picture below.
And also the name of the Map can I generate it based on how many items I have in the list (1st item get 0, 2nd item get 1 and so on...)and add it in when storing? Thank you so much in advance.
Edit:
The dataInt is meant to do the numbering but I failed miserably but still do not know how to get it work.
Update:
I am getting all the List from Firestore.
Firstly the we select some from here:

Then the after selecting it will store the Name into the List
Code of using the List:
List<String> _selectedBusStop = List<String>();
Code of adding to List when onTap and onLongPress
onTap: (){
if(_selectedBusStop.contains(user.data['BusstopName'])){
setState(() {
_selectedBusStop.removeWhere((val) => val == user.data['BusstopName']);
});
}
},
onLongPress: (){
setState(() {
_selectedBusStop.add(user.data['BusstopName']);
});
}
Because the List only have the BusstopName saved in it so I will need to read again from Firestore and get the GeoPoint that I needed. Saved it in a Map and use it as a Polyline. Now I am currently stuck at where I am unable to save all of the Item in the List into the Firestore when I am calling the setData as it only save 1 of the item in the List and I want to store all of it.
Sorry for causing misunderstanding again. Really sorry for that.
Update I am able to store all of the Item in my List into Firestore
void initRoute(data, dataInt) async{
Firestore.instance.collection('routes').document(inputName).setData({
data['BusstopName']:{
"Lat" : data['location'].latitude,
"Lng" : data['location'].longitude
}
}, merge: true);
}
with this code.
