出现这个问题是在提交代码的时候把flutter packages pub run build_runner build生成的xxxx.g.dart也提了上去。运行flutter packages pub run build_runner build不光生成了xxxx.g.dart,同时还成了一个dart_tool/build目录,再生成新的xxxx.g.dart因为缺少之前生成dart_tool/build目下的文件就会报错。
运行两行命令即可:
flutter packages pub run build_runner clean
flutter packages pub run build_runner build --delete-conflicting-outputs