I think I got used to using DocumentSnapshot, without using any ordering or filtering.
Now I am making a query streamer using the code :
Stream<QuerySnapshot> postStream_left = FirebaseFirestore.instance.collection('post')
.where('topic',isEqualTo: received_id)
.where('side',isEqualTo:'left')
.orderBy('like')
.snapshots();
Stream<QuerySnapshot> postStream_right = FirebaseFirestore.instance.collection('post')
.where('topic',isEqualTo: received_id)
.where('side',isEqualTo:'right')
.orderBy('like').snapshots();
return StreamBuilder(stream:postStream_left,builder: (context,snapshot_l)
{
if(!snapshot_l.hasData){
return CircularProgressIndicator();
}
return StreamBuilder(stream:postStream_right,builder: (context,snapshot_r)
{
if(!snapshot_r.hasData){
return CircularProgressIndicator();
}
final documents_l = snapshot_l.data as Map<String,dynamic>; // Here is where I am stuck
final documents_r = snapshot_r.data as Map<String,dynamic>;
print('afepwmcakodepwxa.ofpe,[wambotpmwa');
print(documents_l);
print(documents_r);
return CircularProgressIndicator();
}
);
}
);
What I want to do is show the data of postStream_left and postStream_right in two listview at the same time. However I donot know how to parse the data of each QuerySnapshot, since they did not work with code that works for Documentsnapshot.
type '_JsonQuerySnapshot' is not a subtype of type 'Map<String, dynamic>' in type cast
Here is the error I got but flutter does not tell me how I should cast the data.
Please tell me what to do and thank you very much.