See code at line #8 and #9:
dynamic cache = sharedPreferences.getString(key); var jsonMapCache = jsonDecode(cache) as Map<dynamic, dynamic>;
Line #8, dynamic cache = sharedPreferences.getString(key);, sometimes returns null, which cause error at line 9 when it tries to jsonDecode an empty String. Please add null check around line #9.
See code at line #8 and #9:
dynamic cache = sharedPreferences.getString(key); var jsonMapCache = jsonDecode(cache) as Map<dynamic, dynamic>;
Line #8,dynamic cache = sharedPreferences.getString(key);
, sometimes returns null, which cause error at line 9 when it tries to jsonDecode an empty String. Please add null check around line #9.