Skip to content
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

Using GeoFirePoint with json serializable? #18

Open
giorgio79 opened this issue Nov 13, 2022 · 2 comments
Open

Using GeoFirePoint with json serializable? #18

giorgio79 opened this issue Nov 13, 2022 · 2 comments

Comments

@giorgio79
Copy link

giorgio79 commented Nov 13, 2022

Anyone uses json serializable with GeoFlutterFire's GeoFirePoint?

I suspect we would need a custom JsonConverter for the data? Any tips or code samples?

The GeoPointConverter here works fine https://stackoverflow.com/questions/61707320/how-to-serialize-geopoint-using-dart-json-serializable-package , but here we have geohash too

@emiliodallatorre
Copy link

emiliodallatorre commented Nov 2, 2023

Hi @giorgio79,
it's not that difficult.

You can just set a custom fromJson / toJson on the field of your serializable model.
For instance, my working example is:

@JsonKey(toJson: LocationHelper.geoFirePointToJson, fromJson: LocationHelper.geoFirePointFromJson)
GeoFirePoint? geoPoint;

Here you can find my LocationHelper.


P.S.: @zeusbaba, I think you should close this issue as not relevant.

@adilexperience
Copy link

@emiliodallatorre LocationHelper isn't available in Flutter with this package. Can you provide its flutter code for serialization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants