Hi I am using this code here to retrieve data from Firestore. The data is in a Map
and here is the picture of my Firestore.
And here is my code when I retrieve from Firestore
Future <void> getRoute() async{
Firestore.instance.collection('routes').snapshots().listen((RouteData) {
if(RouteData.documents.isNotEmpty){
for (int i = 0; i < RouteData.documents.length; i++){
_getPolyline(RouteData.documents[i].data, RouteData.documents[i].documentID);
}
}
});
setState(() {
});
}
void _getPolyline(info, infoID) async{
print(info);}
When Im printing the info
it will display the data many times.
here is the result. As you can see it starts off in
test
then test1
then test
again and repeated for some time. Is there something wrong with my code? Thank you in advance.