Replies: 1 comment 1 reply
-
fromFirestore is called only if the document/query you are performing returns a non-null/empty result.
This is the correct solution
Consider a cast: return serializers.serializeWith(Place.serializer, this) as Map<String, Object?>; |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to combine
built_valuewithcloud_firestorein my Flutter project. I believe it makes sense and that is how it should do it in a clean world? (see https://firebase.flutter.dev/docs/firestore/usage/#typing-collectionreference-and-documentreference).This is where I am so far.
The
Placemodel:In the above code, I have two issues:
A value of type 'Object?' can't be returned from the method 'toFirestore' because it has a return type of 'Map<String, Object?>'However, this is a solution that is proposed at multiple locartions (SO questions, github issues), so I don't understand why I get that error.
Placeinstead ofPlace?, as a return value forfromJsonbut then I have the following error:A value of type 'Place?' can't be returned from the method 'fromJson' because it has a return type of 'Place'Could it be related to the null-safety recent changes?
Below are the
serializers(following the doc/tutorials):Finally, here is the place where I want to consume a Firestore collection while using the
Place"data class" defined via thebuilt_valuepackage:It is not working currently because of this line:
toFirestore: (place, _) => place.toFirestore(),.If I return
{}fromtoFirestore()to go through the build and make it work, then I suspectfromFirestore()is not even called: if I placeassert(false);inside the function, nothing happen.. I'd except an exception.Any idea why fromFirestore is not called?
Beta Was this translation helpful? Give feedback.
All reactions