-1

Getting the format exception while passing the token with '|' inside jsonDecode(). enter image description here

final SharedPreferences pref = await SharedPreferences.getInstance();
    value = pref.get("token") as String;
    if (value?.isEmpty ?? true) {
      return null;
    } else {
      final Map<String, dynamic> map = await _parseJson(value);
      return OldToken.fromJson(map);
    }

static Future<Map<String, dynamic>> _parseJson(String text) {
    return compute(_parseAndDecode, text);
  }

static Map<String, dynamic> _parseAndDecode(String response) {
    return jsonDecode(response) as Map<String, dynamic>;
  }
gowthaman C
  • 472
  • 6
  • 16

1 Answers1

1

When you use SharedPreferences you retrieve directly a String, so you don't need to decode a json value.

Antonin GAVREL
  • 9,682
  • 8
  • 54
  • 81