这是我在尝试将网络请求的响应正文解析为 json 映射时仅在发布模式下遇到的错误(奇怪)。我记下了代码以及下面的错误堆栈跟踪。我应该提到的另一件奇怪的事情是它有时只会发生。不是所有的时间。但是对于我在市场上发布的应用程序,当我在 firebase 上查看崩溃报告时,也会报告此错误。(虽然它不会导致崩溃)
我应该提到我使用 Dio 包作为 http 客户端
更新: 我发现它有时会发生,但是当它发生时,当我一遍又一遍地发送相同的请求或有时其他请求时,它会一直发生。直到我退出应用程序并再次运行它。
错误堆栈跟踪:
I/flutter (31714): type '_OneByteString' is not a subtype of type 'Map<String, dynamic>'
I/flutter (31714): #0 Server.getUser (package:mehrgan/data/network/server.dart:83)
I/flutter (31714): <asynchronous suspension>
I/flutter (31714): #1 Future.wait.<anonymous closure> (dart:async/future.dart:0)
I/flutter (31714): <asynchronous suspension>
I/flutter (31714): type '_OneByteString' is not a subtype of type 'Map<String, dynamic>'
I/flutter (31714): #0 Server.getCourses (package:mehrgan/data/network/server.dart:101)
I/flutter (31714): <asynchronous suspension>
I/flutter (31714): #1 Future.wait.<anonymous closure> (dart:async/future.dart:0)
I/flutter (31714): <asynchronous suspension>
我的代码:
Response response = await _dio.get('user/info');
Map<String, dynamic> json = jsonDecode(jsonEncode(response.data));