Cannot read property 'Symbol(dartx._get)' of null

5,404

Solution 1

CORS Related Issue

My Flutter Web app communicates with an Azure Function. The iOS and Android versions worked fine, but I was getting the property 'Symbol(dartx._get)' of null error above when attempting to execute a graphql query against the azure function in flutter web. Chetan's CORS hint in the comment above gave me a clue.

This Stack Overflow Q&A resolved the issues I have having on production and localhost. CORS with Azure function from localhost (not CLI)

Solution 2

Sometimes it may happen due to uninitialized Map Fields on set operation, So initialze it,

Map<String> jsonResult;

To

Map<String> jsonResult={};
Share:
5,404
chetan mahajan
Author by

chetan mahajan

I’m an IoT Developer living in Ahmedabad, India. I am a fan of IoT, android, and python. I’m also interested in AWS IoT and Firebase Database.

Updated on December 25, 2022

Comments

  • chetan mahajan
    chetan mahajan over 1 year

    I'm trying to call API in the web app is show this error and Android and iOS Working fine. I don't understand why happening.I'm using retrofit and dio to call api's.

       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 {
              Constants.toast(apiError.message);
            }
          }
        }
    

    I got this error

    TypeError: Cannot read property 'Symbol(dartx._get)' of null
        at new service_errors.ApiError.fromJson (http://localhost:44059/packages/web_app/service_errors/service_errors.dart.lib.js:103:36)
        at service_errors.ServiceError.new.getError (http://localhost:44059/packages/web_app/service_errors/service_errors.dart.lib.js:23:22)
        at http://localhost:44059/packages/web_app/forgot_password/reset_password.dart.lib.js:6485:58
        at _RootZone.runUnary (http://localhost:44059/dart_sdk.js:37533:58)
        at _FutureListener.catchError.handleError (http://localhost:44059/dart_sdk.js:32521:48)
        at handleError (http://localhost:44059/dart_sdk.js:33070:51)
        at Function._propagateToListeners (http://localhost:44059/dart_sdk.js:33096:17)
        at _Future.new.[_completeError] (http://localhost:44059/dart_sdk.js:32943:23)
        at async._AsyncCallbackEntry.new.callback (http://localhost:44059/dart_sdk.js:32981:31)
        at Object._microtaskLoop (http://localhost:44059/dart_sdk.js:37794:13)
        at _startMicrotaskLoop (http://localhost:44059/dart_sdk.js:37800:13)
        at http://localhost:44059/dart_sdk.js:33309:9
    

    Not realy sure what is actually causing the issue, hope you can help. Thank you so mush.