Skip to content

Instantly share code, notes, and snippets.

@aduquet
Created March 25, 2022 08:21
Show Gist options
  • Save aduquet/4ee969c2042b0263d5b7387481cb97d7 to your computer and use it in GitHub Desktop.
Save aduquet/4ee969c2042b0263d5b7387481cb97d7 to your computer and use it in GitHub Desktop.
type 'Future<dynamic>' is not a subtype of type 'Stream<Object?>?'
I was dealing with
type 'Future<dynamic>' is not a subtype of type 'Stream<Object?>?'
I had no Future types in my app however I did have something like this:
getQuestion(String id, String collectionName) async {
//var collection = FirebaseFirestore.instance.collection(collectionName);
// var querySnapshots = await collection.get();
// for (var snapshot in querySnapshots.docs) {
// var documentID = snapshot.id;
// print('++++++++++++++++++++++++++');
// print(documentID); // <-- Document ID
// }
// final docsID = FirebaseFirestore.instance.collection(collectionName).doc();
// print('++++++++++++++++++++++++++');
// print(docsID);
// print(FirebaseFirestore.instance.collection(collectionName).doc());
return FirebaseFirestore.instance
.collection(collectionName)
.doc(id) //ID OF DOCUMENT
.snapshots();
}
}
I found that You cannot use async/await when returning from a build method (or a builder closure).
so the solution was to delate the async stament :D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment