🌋
2021/01時点 flutter freezed の build が無限に終わらない時のたったひとつのcoolな解決法
TL;DR
- pubspec.yaml の
dependencies
にanalyzer
を追加して再ビルドすればOK
症状:ちょっと古いプロジェクトの freezed build が無限に終わらない
flutter packages pub run build_runner build --delete-conflicting-outputs
したときに、
[INFO] 17.7s elapsed, 1/9 actions completed.
[INFO] 18.8s elapsed, 1/9 actions completed.
[INFO] 19.9s elapsed, 1/9 actions completed.
[INFO] 20.9s elapsed, 1/9 actions completed.
[INFO] 22.0s elapsed, 1/9 actions completed.
[INFO] 23.0s elapsed, 1/9 actions completed.
...
と出力が出続けて無限に終わらない状況になることがある(なった)
原因:たぶんこれ……かな……?
※monoさんいつもありがとうございます
dependencies
に analyzer
を追加して再ビルド
解決法:pubspec.yaml
dependencies:
analyzer: ^0.39.14 # <- 追記
これでもいけるらしい
pubspec.yaml
dependency_overrides:
analyzer: ^0.39.14 # <- 追記
綺麗にしてから再ビルド。
rm -rf pubspec.lock
flutter clean
flutter pub get
flutter packages pub run build_runner build --delete-conflicting-outputs
いけた!
[INFO] 6.4s elapsed, 0/9 actions completed.
[INFO] 7.5s elapsed, 0/9 actions completed.
[INFO] 8.5s elapsed, 0/9 actions completed.
[INFO] 9.8s elapsed, 0/9 actions completed.
[INFO] 10.8s elapsed, 0/9 actions completed.
[INFO] 12.3s elapsed, 1/9 actions completed.
[INFO] 13.4s elapsed, 1/9 actions completed.
[INFO] 15.8s elapsed, 1/9 actions completed.
[INFO] 16.8s elapsed, 2/9 actions completed.
[INFO] 19.7s elapsed, 4/9 actions completed.
[INFO] 21.9s elapsed, 5/9 actions completed.
[INFO] 22.9s elapsed, 23/31 actions completed.
[INFO] Running build completed, took 23.1s
参考
- 【Flutter, Dart, freezed】Bad state: Unexpected diagnosticsでbuildが終わらない不具合 | Qiita
- flutter build_runnerが動かなかったときの対処法 | misoniction.com
- [Flutter]Flutterのバージョンを1.20に上げたらbuild_runnerが失敗するようになった場合の対処法(Bad state: Unexpected diagnostics・・This requires the ‘non-nullable’ language feature to be enabled) | プログラミング挫折撲滅プロジェクト・みんなのプログラミング by Telulu LLC(FlutterでiOS/Androidスマホアプリ開発)
Discussion