Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Method not found: 'NullThrownError' in flutter

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();
                                       ^^^^^^^^^^^^^^^
like image 800
Sanakhatun Shaikh Avatar asked Jun 14 '26 09:06

Sanakhatun Shaikh


1 Answers

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
like image 116
Ali Mahfud Avatar answered Jun 17 '26 00:06

Ali Mahfud



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!