Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equlent libary avalable in flutter dart like Gson in java

Is there any library available to save object and restore it.
In android java we using Gson to do this but in flutter there is no Gson

like image 205
Midhilaj Avatar asked Feb 03 '23 20:02

Midhilaj


2 Answers

A library like GSON won't be possible in Flutter, since Flutter doesn't support code reflection. Reflection interferes with tree shaking which flutter needs to clean out unused code and give a compact app.

more on the topic and alternatives here

You can use this site to convert your JSONs to class and it prepares the toJson fromJson methods automatically.

like image 74
ir2pid Avatar answered Feb 06 '23 16:02

ir2pid


I am using this website and it saves my time
no need to think just past the JSON code here then it will generate the prefect dart class code
https://app.quicktype.io/

like image 38
Midhilaj Avatar answered Feb 06 '23 16:02

Midhilaj