小编che*_*jan的帖子

无法读取 null 的属性“Symbol(dartx._get)”

我正在尝试在 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)

web flutter flutter-web

5
推荐指数
1
解决办法
3158
查看次数

标签 统计

flutter ×1

flutter-web ×1

web ×1