Flutter build_runner watch Not Working | The getter 'definingUnit' was called on null Flutter build_runner watch Not Working | The getter 'definingUnit' was called on null flutter flutter

Flutter build_runner watch Not Working | The getter 'definingUnit' was called on null


To me, arpit solution worked: "Downgrading build_runner to 1.10.2".

(Added on 27 November 2020):

In other cases, the problem may arise if there is some import with "//" in it, eg.:

`import 'package:path//name.dart'.

Here is a regular expression to find the "import" that have "//" in the same line:

(import).*?(//).*?

This solution is taken from https://github.com/google/json_serializable.dart/issues/738, see dotdotcommadot answer.


I was having this same issue earlier today. For me what worked was delete all tests files and making the build_runner downgrade to 1.10.2. I know this is not the best solution but it is a workaround for a while.


Given that your problem stems from an analyzer and your build is waiting for the auto_route_generator library, and that library has a newer version than the one you use that as it's only change had "Restrict analyzer version to ">=0.40.0 <2.0.0" I'll take a guess and say you should update that.