IbrahimDevp / flutter_auth

0 stars 0 forks source link

fromJson() function in model classes #8

Open adnsawas opened 1 year ago

adnsawas commented 1 year ago

https://github.com/ikema77/flutter_auth/blob/0b86b7d22c968fdd363c173abcfbd6dd2510f919/lib/providers/info.dart#L72-L79

Add fromJson() function in model classes. For example, Info ChangeNotifier class should not worry about creating a User object. It should just pass a json variable to User.fromJson() function. And this function inside User class knows how to convert a json into a User object.

Check this out: Json serialization inside model classes