Home > Software engineering >  The argument type 'Future<QuerySnapshot<Map<String, dynamic>>>' can'
The argument type 'Future<QuerySnapshot<Map<String, dynamic>>>' can'

Time:02-16

I want after Login return me data to specific user. To get it i will do query which searches the documents for the ID that the user sent to the userId field automatically during registration but when i want to induce my query give me error: The argument type 'Future<QuerySnapshot<Map<String, dynamic>>>' can't be assigned to the parameter type 'Future<DocumentSnapshot<Object?>>?'

enter image description here

enter image description here

CodePudding user response:

What you're doing right now is fetching a collection of users that match on that criteria, which will return you a list (hence QuerySnapshot). If you want the single document associated with the logged in user (a DocumentSnapshot), you'd have to do:

FirebaseFirestore.instance.collection('users').doc(user!.uid).get()

which should return a Future with a DocumentSnapshot, and you can capture its data in the builder callback handler of the FutureBuilder via the snapshot provided in the callback.

  • Related