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.