Flutter NoSuchMethodError: The getter 'references' was called on null. のエラーが出てやったこと

by dicekest,

はじめに

Flutterのプロジェクトで json_serializable を使ってモデルの作成を行なっていますが、 新しくモデルを作ろうとしたら以下のエラーが発生してやったことを残しておきます。

環境は以下の通り

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Mac OS X 10.14.6 18G95, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.38.1)
[✓] Connected device (1 available)
  json_serializable: 3.2.2

起きたこと

モデル作成を実行したら

flutter packages pub run build_runner build --delete-conflicting-outputs

以下のようにエラーが発生した。

You have hit a bug in build_runner
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues


NoSuchMethodError: The getter 'references' was called on null.
Receiver: null
Tried calling: references
dart:core                                                         Object.noSuchMethod
package:analyzer/src/summary2/linked_bundle_context.dart 22:47    new LinkedBundleContext
package:analyzer/src/dart/analysis/library_context.dart 407:11    LibraryContext._createElementFactory
package:analyzer/src/dart/analysis/library_context.dart 94:7      new LibraryContext
package:analyzer/src/dart/analysis/driver.dart 1439:29            AnalysisDriver._createLibraryContext
package:analyzer/src/dart/analysis/driver.dart 1380:28            AnalysisDriver._computeUnitElement.<fn>
package:analyzer/src/dart/analysis/performance_logger.dart 34:15  PerformanceLog.run
package:analyzer/src/dart/analysis/driver.dart 1378:20            AnalysisDriver._computeUnitElement
package:analyzer/src/dart/analysis/driver.dart 997:34             AnalysisDriver.performWork
package:analyzer/src/dart/analysis/driver.dart 1931:24            AnalysisDriverScheduler._run
package:analyzer/src/dart/analysis/driver.dart 1865:5             AnalysisDriverScheduler.start
package:build_resolvers/src/analysis_driver.dart 54:13            analysisDriver
package:build_resolvers/src/resolver.dart 138:18                  new AnalyzerResolvers
package:build_runner_core/src/generate/options.dart 193:19        BuildOptions.create
package:build_runner/src/generate/build.dart 85:36                build
package:build_runner/src/entrypoint/build.dart 28:24              BuildCommand.run
package:args/command_runner.dart 197:27                           CommandRunner.runCommand
package:args/command_runner.dart 112:25                           CommandRunner.run.<fn>
dart:async                                                        new Future.sync
package:args/command_runner.dart 112:14                           CommandRunner.run
package:build_runner/src/entrypoint/run.dart 24:31                run
.dart_tool/build/entrypoint/build.dart 22:22                      main

やったこと

flutter packages pub upgrade

flutterのバージョンアップしたら pub upgrade をしないといけないんだなというメモ