podcast_search icon indicating copy to clipboard operation
podcast_search copied to clipboard

Would be nice if all models were json serializable

Open sgehrman opened this issue 1 year ago • 3 comments

I want to pass from backend to frontend, and it would be easier if they would serialize to json.

sgehrman avatar Oct 22 '23 13:10 sgehrman

Hi @sgehrman,

This is an interesting idea. Are you thinking of just being able to serialise the models to JSON, or also thinking of de-serialising JSON back into the models?

amugofjava avatar Nov 08 '23 16:11 amugofjava

Flutter doesn't support Reflection like Java. So you cannot see any framework like GSON. Actually, Dart language supports mirror, which is similar to Reflection, but this feature was ignored by Flutter

loveoverflowdev avatar Dec 26 '23 03:12 loveoverflowdev

You're right, Flutter doesn't support reflection but there are ways this request can be achieved. You can serialise/deserialise objects to/from JSON manually (my preferred approach) or via code gen using a package such as json_serializable.

amugofjava avatar Dec 26 '23 10:12 amugofjava