I'm trying to save a Map<String, List<MyObj>>
in sharedPreferences.
I tried to use the classic sharedPreferences
package, but I'm having trouble.
If I save a string to sharedPreferences, then when I try to retrieve and use json.decode(...)
,
I get the error Unhandled Exception: FormatException: Unexpected character (at character 2)...
If I try to save it using json.encode(...)
, I get the error Unhandled Exception: Converting object to an encodable object failed: Instance of 'MyObj'
.
What I'm trying to save is like this:
{ExampleString: [Instance of 'MyObj', Instance of 'MyObj'...], ExampleString2: [Instance of 'MyObj', Instance of 'MyObj'...], ...}
How can I solve this?
Is there a package that allows you to save map?