Search code examples
flutterdartflutter-webflutter-testdart-null-safety

'dfg throw' isn't a type.foundation/changenotifier.dart:125 in flutter


I got this issues suddenly while debugging on Emulator.

     'throw' isn't a type.foundation/changenotifier.dart:125 throw FlutterError( ^^^^^^^^ :
 Error: Expected ';' after this. ../…/foundation/changenotifier.dart:125 throw FlutterError( ^^^^^^^^^^^^ : Error:

Solution

  • I had resolved the issues by upgrading to the latest Flutter SDK version 3.3.2.

    Actually in Flutter SDK ,If you find the file changenotifier.dart file. at this location /Users/sumitjaiswal/Desktop/flutter/packages/flutter/lib/src/foundation

    You will find this code .

    static bool debugAssertNotDisposed(ChangeNotifier notifier) {
        assert(() {
          if (notifier._debugDisposed) {
            throw FlutterError(
              'A ${notifier.runtimeType} was used after being disposed.\n'
              'Once you have called dispose() on a ${notifier.runtimeType}, it '
              'can no longer be used.',
            );
          }
          return true;
        }());
        return true;
      }
    

    This has changed from dfg throw to throw. So,I had just upgrade to latest version of Flutter SDK 3.3.2.