2

I was getting the below error while running the flutter application post flutter upgrade to 3.10.6

Failed to build build_runner:build_runner:
/C:/Users/Admin/AppData/Local/Pub/Cache/hosted/pub.dev/build_runner-2.3.2/lib/src/build_script_generate/bootstrap.dart:76:40: Error: Method not found: 'NullThrownE
rror'.
      final error = e[0] as Object? ?? NullThrownError();
                                       ^^^^^^^^^^^^^^^
Sanakhatun Shaikh
  • 2,089
  • 3
  • 11
  • 18

3 Answers3

0

Resolved issue by upgrading build_runner dependency

Steps:

  1. Open Project in Android Studio

  2. Navigate to Terminal Tab in Android Studio

  3. Execute the below command

    $ flutter clean

    $ flutter pub get

    $ flutter pub upgrade

    $ flutter pub run build_runner build --delete-conflicting-outputs

  4. Run the application.

The above solution worked for me. Hope, it will help to others as well.

Sanakhatun Shaikh
  • 2,089
  • 3
  • 11
  • 18
0

I use flutter3.10.5 version, and I also encountered the same error when using build_runner. Confusing enter image description here

DolDurma
  • 15,753
  • 51
  • 198
  • 377
robin
  • 1
  • 1
  • ➜ untitled dart run build_runner build Building package executable... Failed to build build_runner:build_runner: ../../.pub-cache/hosted/pub.dev/build_runner-2.2.0/lib/src/build_script_generate/bootstrap.dart:76:40: Error: Method not found: 'NullThrownError'. final error = e[0] as Object? ?? NullThrownError(); ^^^^^^^^^^^^^^^ – robin Jul 26 '23 at 11:42
  • I tried $ flutter pub run build_runner build --delete-conflicting-outputs command, kindly check with this if it may help you. – Sanakhatun Shaikh Jul 29 '23 at 07:30
  • Thanks for the help. I have tried both $ flutter pub upgrade and $ flutter pub run build_runner build --delete-conflicting-outputs commands, but I still get the same error message as before. – robin Jul 31 '23 at 05:52
  • i have same issue bad days – Yogi Arif Widodo Aug 16 '23 at 05:05
  • ``` pub-cache/hosted/pub.dev/build_runner-2.2.0/lib/src/build_script_generate/bootstrap.dart:76:40: Error: Method not found: 'NullThrownError'. final error = e[0] as Object? ?? NullThrownError(); ``` – Yogi Arif Widodo Aug 16 '23 at 05:06
0

This what worked for me

  • delete pubspec.lock
  • flutter pub cache clean
  • flutter clean
  • flutter upgrade (probably optional)
  • flutter pub get
  • flutter pub run build_runner build --delete-conflicting-outputs
Vaygeth
  • 156
  • 8