Converting Dart Objects To Strings And Back With JsonEncode/Decode
Convert Dart object to string and back using `jsonDecode` and `jsonEncode` methods from `dart:convert`. For complex objects, provide custom `toJson` and `fromJson` methods.
I want to share simple way how convert dart object to string and back. Certainly, you can use special library for it. But in my case, you can use only library dart.convert; that included in standard Dart SDK. To convert from string to object, you can use method: jsonDecode(jsonString) for opposite operation, you should use: jsonEncode(someObject) If your object contains more complex structures inside than simple types, you should provide additional methods, like in the example below. class CustomClass { final...