Flutter DocumentSnapshot - Error: A value of type 'Object?' can't be assigned to a variable of type 'DocumentSnapshot'
1,345
Do DocumentSnapshot snap = snapshot.data as DocumentSnapshot;
Author by
han da
Updated on December 29, 2022Comments
-
han da over 1 year
return StreamBuilder( stream: usersRef.doc(post.userId).snapshots(), builder: (context, snapshot) { if (snapshot.hasData) { DocumentSnapshot snap = snapshot.data; UserModel user = UserModel.fromJson(snap.data()!);
Hello, all! The 'snapshot.data' is giving me the above error. Please, help! Thanks!
-
Nikhil Badyal about 3 yearsWrite like this
DocumentSnapshot snap = snapshot.data as DocumentSnapshot ;
-
han da about 3 yearsoh... that was easy! lol thanks, @Problematic Dude!
-
Nikhil Badyal about 3 yearsdoes it Worked ?
-
han da about 3 yearsthe error is gone. but am stuck on a different issue. not yet checked... but, thanks anyways!
-
Nikhil Badyal about 3 yearsIn that case I'm adding above comment as an answer. Mark it if error in the question is gone
-