How to encode an object to json in Flutter

Posted by Jennifer | Updated on

If you want to encode an object to json in Flutter? To make my code work I needed to implement the toJson() methods at my class Goal as well (because I used List in Week).

Also, I needed to add .toIso8601String() to the DateTime objects like that in the Week class:

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@] Your question and answer will appear on and help other developers.

Related Questions & Answers