I've been struggling with an error that is apparently due to new changes of DocumentSnapshot that I'm trying to use in a FutureBuilder
you can see how i'm using it below :
body: FutureBuilder(
future: usersRef.doc(widget.userId).get(),
builder: ( context, snapshot) {
List<Widget> children;
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(),
);
}
else if (snapshot.hasData) {
UserModel user = UserModel.fromDoc(snapshot.data);
factory UserModel.fromDoc(DocumentSnapshot doc) {
return UserModel(
id: doc.id,
name: doc['name'],
username: doc['username'],
password: doc['password'],
profileImageUrl: doc['profileImageUrl'],
email: doc['email'] ,
userIds: doc['userIds'] ?? '',
);
}
I encounter this error:
The following StateError was thrown building FutureBuilder<DocumentSnapshot>(dirty, state: _FutureBuilderState<DocumentSnapshot>#46a8d):
Bad state: cannot get a field on a DocumentSnapshotPlatform which does not exist
I already tried to solve it using the solution that I found on this github issue ( https://github.com/FirebaseExtended/flutterfire/issues/3826) but It didn't really solve it.
I'll be so appreciative if any of you help me with this
Thanks
question from:
https://stackoverflow.com/questions/65862565/documentsnapshot-in-a-futurebuilder-bad-state-cannot-get-a-field-on-a-documen 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…