【发布时间】:2021-02-15 05:19:47
【问题描述】:
使用“|”传递令牌时获取格式异常在 jsonDecode() 中。
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>;
}
【问题讨论】:
-
看不到您的问题,因为这里的图片被屏蔽了。最好以文本形式提供。
-
我认为如果您可以发布失败的 JSON 输入片段,这将有助于其他人更好地理解。
-
哪一行出错了??
-
我在 jsonDecode() 方法@JanviPatel 中得到格式异常
标签: flutter flutter-dependencies dio