Reputation: 2339
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();
^^^^^^^^^^^^^^^
Upvotes: 8
Views: 5281
Reputation: 2376
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
Upvotes: 0
Reputation: 1
You can remove build_runner-(*any version or variant) package/s in .../AppData/Local/Pub/Cache/hosted/pub.dev
It works for me.
Upvotes: 0
Reputation: 303
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:
retrofit_generator
, floor_generator
and build_runner
from dev_dependenciesflutter pub add dev:build_runner
, flutter pub add dev:floor_generator
and flutter pub add dev:retrofit_generator
dart run build_runner build
or if the error still occur try this package version:
Upvotes: 11
Reputation: 1
Try dependecy follwing version in you pubspec.yaml file
retrofit_generator: ^7.0.8 build_runner: ^2.1.0
Upvotes: 0
Reputation: 1
I use flutter3.10.5 version, and I also encountered the same error when using build_runner. Confusing enter image description here
Upvotes: 0
Reputation: 184
This what worked for me
flutter pub cache clean
flutter clean
flutter upgrade
(probably optional)flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
Upvotes: -1
Reputation: 2339
Resolved issue by upgrading build_runner dependency
Steps:
Open Project in Android Studio
Navigate to Terminal Tab in Android Studio
Execute the below command
$ flutter clean
$ flutter pub get
$ flutter pub upgrade
$ flutter pub run build_runner build --delete-conflicting-outputs
Run the application.
The above solution worked for me. Hope, it will help to others as well.
Upvotes: 4