8

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();
                                       ^^^^^^^^^^^^^^^

7 Answers 7

11

For me this happen because the incompatibility of each package used. I think the packages that relate to build runner are floor_generator and retrofit_generator. You can simply resolve the issue by following these:

  • remove retrofit_generator, floor_generator and build_runner from dev_dependencies
  • add packages from terminal -> flutter pub add dev:build_runner, flutter pub add dev:floor_generator and flutter pub add dev:retrofit_generator
  • try to build the build_runner again -> dart run build_runner build

or if the error still occur try this package version:

  • dependencies: floor: ^1.4.2 retrofit: ^3.0.1
  • dev_dependencies: build_runner: ^2.4.6 retrofit_generator: ^4.2.0 floor_generator: ^1.4.2
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @AliMahfud! it helped me with your first solution. <3
4

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.

Comments

0

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

6 Comments

➜ 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(); ^^^^^^^^^^^^^^^
I tried $ flutter pub run build_runner build --delete-conflicting-outputs command, kindly check with this if it may help you.
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.
i have same issue bad days
``` 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(); ```
|
0

Try dependecy follwing version in you pubspec.yaml file

retrofit_generator: ^7.0.8 build_runner: ^2.1.0

1 Comment

it should be comment not an answer.
0

You can remove build_runner-(*any version or variant) package/s in .../AppData/Local/Pub/Cache/hosted/pub.dev

It works for me.

1 Comment

add more details!
0

This is what worked for me as I'm having Dart project:

dart pub upgrade

But if your project is Flutter, run this:

flutter pub upgrade

Comments

-1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.