我正在尝试在 Web 应用程序中调用 API 显示此错误并且 Android 和 iOS 工作正常。我不明白为什么会发生。我正在使用改造和 dio 来调用 api。
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:web_app/utils/constants.dart';
class ServiceError {
static BuildContext context;
ServiceError(BuildContext context) {
context = context;
}
void getError(final res) {
print("MyError" + res.toString()); // I got null value and this working fine in android and iOS. only i get problem in web app
final jsonResponse = jsonDecode(res.toString());
ApiError apiError = ApiError.fromJson(jsonResponse);
print("MyError" + apiError.status);
print("MyCode" + apiError.message);
if (apiError.responseCode == 500) {
Constants.toast(apiError.message);
} else …Run Code Online (Sandbox Code Playgroud)