You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a large app using built_value and I'm migrating it to using freezed (and with that json_serializable). This would allow me to cut out a huge amount of boilerplate and give me all the lovely freezed features like deep copy etc.
The app has data models that are shared between the client and server. When they are serialized to/from Firestore the DateTime objects are converted to Timestamps. With built_value I have two sets of serializers, one results in pure Dart DateTime objects and the other (firestoreSerializers) handles the pesky Timestamps, as these are passed to and from the json methods I have the flexibility to use the necessary serializers based on the context:
Is there a way to accomplish something similar to this with freezed? I basically need handle the serialization & deserialization of DateTime's differently according to context requirements? There are situations where both the client and server need to serialize & deserialize objects to/from firestore as well as none-Firestore contexts (sending/receiving the objects with cloud-endpoint, caching etc).
I've looked at using package:flutterfire_json_converters which seems to address my issue but then there isn't any way to handle dart only environments.
Thanks
The text was updated successfully, but these errors were encountered:
Hey @rrousselGit thanks for the response. I have looked at JsonConverter but I don't think it solves my requirement as I don't believe it gives me the ability to handle DateTime as Timestamps or DateTime's according to requirements. I might have missed a trick with it though?
I have a number of Cloud Run endpoints using the dart SDK (no flutter) using these models, in this situation I need the time fields to serialize/deserialize as DateTime's. I'm not even sure how this would look with freezed? I played around with a custom object with branching imports but I'm not sure if that would work. In the flutter client I need the same default behavior (DateTime objects) but with the ability to serialize+deserialze all the DateTIme fields to Timestamp's when communicating to/from Firestore.
Yeah I'm aware of JsonConverter but my question/reporting lack of documentation was around how to switch which JsonConverter I'm using at runtime. I had hoped maybe there was a solution in freezed for this kind of thing but I'll try json_serializable. Thanks
Hi, I have a large app using
built_value
and I'm migrating it to usingfreezed
(and with thatjson_serializable
). This would allow me to cut out a huge amount of boilerplate and give me all the lovely freezed features like deep copy etc.The app has data models that are shared between the client and server. When they are serialized to/from Firestore the DateTime objects are converted to Timestamps. With built_value I have two sets of serializers, one results in pure Dart DateTime objects and the other (
firestoreSerializers
) handles the pesky Timestamps, as these are passed to and from the json methods I have the flexibility to use the necessary serializers based on the context:Is there a way to accomplish something similar to this with freezed? I basically need handle the serialization & deserialization of DateTime's differently according to context requirements? There are situations where both the client and server need to serialize & deserialize objects to/from firestore as well as none-Firestore contexts (sending/receiving the objects with cloud-endpoint, caching etc).
I've looked at using
package:flutterfire_json_converters
which seems to address my issue but then there isn't any way to handle dart only environments.Thanks
The text was updated successfully, but these errors were encountered: