I'm trying to use streambuilder to receive data and turn this data to json for my model but getting error below; So my question is how can i convert stream data from firebase to json
Error
type 'QueryDocumentSnapshot' is not a subtype of type 'Map<dynamic, dynamic>'
FromJson method of model
factory Review.fromJson(Map<dynamic, dynamic> json) => Review(
//Bunch of random fields here);
StreamBuilder
StreamBuilder<Object>(
stream: widget.reviewStream,
builder: (context, AsyncSnapshot snapshots) {
if (snapshots.hasData) {
var data = snapshots.data.docs;
return ListView.builder(
shrinkWrap: true,
itemCount: data.length,
itemBuilder:
(BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 12.0),
child: Padding(
padding:
const EdgeInsets.all(8.0),
child: ReviewBox(
review: Review.fromJson(
data[index]),
user: widget.user,
)),
);
},
);
} else {
return Text('No Data');
}
}),
question from:https://stackoverflow.com/questions/66059444/convert-querydocumentsnapshot-to-json