This is how my data look like. I'm trying to convert a map field object in Firestore to flutter.
If there isn't a rating map in my Firestore database, I can easily use the following code to convert the data in Flutter
firestore.collection('test').doc('I1raMaJArb1sWXWqQErE')
.snapshots().listen((snapshot) {
if (snapshot.docs != null) {
var map = snapshot.docs;
if (map != null) {
map.forEach((change) {
Review review = Review.fromJson(change.data());
});
}
But with the rating map in Firestore, I'm not sure how to convert it. Can anyone share how they would convert a map datatype in Firestore to flutter? Thanks in advance!
Below shows the code for the model.
class Reviews {
String UserID;
String UserName;
//what do I put for the rating
Review({
this.UserID,
this.UserName
//what do I put for the rating
});
factory ChatChannel.fromJson(Map<dynamic, dynamic> json) => ChatChannel(
UserID: json['UserID'],
UserName: json['UserName'],
//what do I put for the rating
);
Map<String, dynamic> toJson() => {
"UserID": UserID,
"UserName": UserName,
//what do I put for the rating
);
}
