I have the same func in different files, but here i got an error
Map<String, dynamic>? getJson(String key) =>
_sharedPreferences.getString(key)?.let((it) => jsonDecode(it));
The return type 'dynamic' isn't a 'Map<String, dynamic>?',
as required by the closure's context.dartreturn_of_invalid_type_from_closure
CodePudding user response:
You need to cast it, see below
Map<String, dynamic>? getJson(String key) =>
_sharedPreferences.getString(key)?.let((it) => (jsonDecode(it) as Map<String, dynamic>));