Wrong assignment done here. change the above code
Future _onPressed() async{
var docSnap = await db.collection('Messages').doc(widget.brew.id).get();
if (docSnap.exists) {
print('Document data: ${documentSnapshot.data()}');
return docSnap.data()['Message'];
} else {
print('Document does not exist on the database');
return docSnap.data()['Message'];
}
}
In current snippet, msg.data()
throws the err as the msg was null at that time.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…