-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in db.dart for Collection.streamData #11
Comments
Hey, I might have found the solution for your problem. I was facing the same problem as you did, while browsing in the depth of the StackOverflow, I found this Hope it helps after 11 months :) |
Haha. Thanks. :) Adding .toList() to the end of line 47 was the answer, by the way. I'm not sure if I had made that clear in my description of the issue. Technically, I probably should have just submitted a PR with the solution/update... |
Thank you! I was running into the same issue and adding the toList() worked for me. |
Hi, I was trying to fetch data from firestore using provider and this exception was thrown, have no idea what went wrong.
The following assertion was thrown: listened by ADDRESS CLASS DATABASE SERVICE getAddress(){
**I have used another provider in the same project for different collection and it worked fine, just the address is giving hard time |
When you upgrade your firestore you'll wind up with a different set of errors with one related to the streamData. I can't figure it out. Stream<List> streamData() { gives: |
You need to add a () somewhere in your code. The error is that it wants a map as its return value, but it is instead receiving a function that creates a map... Hence the () before => Map... Assuming everything worked before the upgrade, you may want to consider changing doc.data to doc.data() @jrheisler let me know if that was your issue. |
Exactly, but I changed it on the receiving end in the model to data(). Thank you!!! |
I added my problem on SO. Putting the v.data() solved the error of Map subtypes, but now I get the stream returned as null. I don't understand what is going wrong here. I've printed the user id too and it shows correctly in the switchmap. https://stackoverflow.com/questions/66092838/firestore-document-stream-of-user-data Any help? @FireJuun @jrheisler |
it working <3! |
@LongKhoa0706 that was exactly how I fixed the issue on my side. |
======== Exception caught by provider ============================================================== StreamProvider<List>, but no Exception: ==================================================================================================== |
I am having this exact error. Were you able to find a fix? |
db.dart provides an excellent, abstract means to connect Firestore documents and collections to Flutter without all the boilerplate. However, I noticed a bug when working with streams in db.dart. When creating a stream collection, such as by calling:
StreamProvider<List<Example>>.value(value: Global.exampleRef.streamData())
...inside of a MultiProvider widget, you will get the following error message:
In db.dart, Line 47 is missing a .toList() at the end:
Stream<List<T>> streamData() { return ref.snapshots().map((list) => list.documents.map((doc) => Global.models[T](doc.data) as T).toList()); }
The text was updated successfully, but these errors were encountered: