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
I followed your steps on the annotation (Weather_tutorial) and I wanted to use that lesson to solve the issue of writing an object to json. I think the your work with annotation/build is well explained in your video(s) but does not address the obj to json issues I am experiencing. After reading/browsing for 3 days on and off I can not find an example that converts an object to a json string. I did read that one has to add the following to the BaseResponse.dart file after the factory(s) statement:
Map<String, dynamic> toJson() => _$BaseResponse(this);
The ..g.. file is created but now I have a usage issue. Everything I have read for the past few days ALWAYS gives fromJson (populate object from json string) vs toJson(object to json string).
It wasn't required for this particular example but there is plenty of documentation around the built_value library and its examples.
Even with this example, there are toJson functions which were created in the response.g.dart file. You can just implement them the same way that I added the fromJson functions and then use them as you would with any other toJson function.
Sorry it took me so long to respond, I don't check these repositories.
Uh oh!
There was an error while loading. Please reload this page.
I followed your steps on the annotation (Weather_tutorial) and I wanted to use that lesson to solve the issue of writing an object to json. I think the your work with annotation/build is well explained in your video(s) but does not address the obj to json issues I am experiencing. After reading/browsing for 3 days on and off I can not find an example that converts an object to a json string. I did read that one has to add the following to the BaseResponse.dart file after the factory(s) statement:
Map<String, dynamic> toJson() => _$BaseResponse(this);
The ..g.. file is created but now I have a usage issue. Everything I have read for the past few days ALWAYS gives fromJson (populate object from json string) vs toJson(object to json string).
This link came close using jsonEncode but the userMap came from a jsonString.

ref: https://flutter.dev/docs/development/data-and-backend/json#consuming-json_serializable-models
any help or refs are welcome !
The text was updated successfully, but these errors were encountered: