How to encode an object to json in Flutter

Posted by Jennifer | Updated on | Flutter

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[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers