Flutter 2.8.4 -> 3.0.0 にアップグレードする

fvm を利用したプロジェクトをアップグレードする。

$ fvm releases
--------------------------------------
May 11 22  │ 3.0.0             stable
--------------------------------------

$ fvm install 3.0.0
$ fvm use 3.0.0
$ fvm flutter --version
Flutter 3.0.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ee4e09cce0 (6 days ago) • 2022-05-09 16:45:18 -0700
Engine • revision d1b9a6938a
Tools • Dart 2.17.0 • DevTools 2.12.2

$ fvm flutter pub upgrade
$ fvm flutter pub upgrade --major-versions
$ fvm flutter pub outdated   
Showing outdated packages.
[*] indicates versions that are not the latest available.

Package Name              Current  Upgradable  Resolvable  Latest  

direct dependencies: all up-to-date.

dev_dependencies: all up-to-date.


$ fvm flutter run
...
    [!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
      In snapshot (Podfile.lock):
        Firebase/CoreOnly (= 8.9.0)

      In Podfile:
        firebase_core (from `.symlinks/plugins/firebase_core/ios`) was resolved to 1.17.0, which depends on
          Firebase/CoreOnly (= 8.15.0)
...

# Cocoapods でエラーが出ている

$ pod repo update
$ fvm flutter run

これでひとまず Flutter の環境の更新は完了。

手元のプロジェクトでは以下のエラー、ワーニングを修正。

warning

dart fix

$ fvm dart fix --apply

大体が Sort child properties last in widget instance creations. の warning だった。あとWidgetsBinding.instance。

手動で warning 修正

  • use_build_context_synchronously -context を利用する前に if (!mounted) return;を入れるか then を利用する
  • depend_on_referenced_packages
    • flutter_hooks などが明示的に pubspec.yml になかったので追記

エラー修正

List の firstOrNull がなくなった?

- hogeList.firstOrNull;
+ hogeList.isEmpty ? null : splitNames.first;

おわり

コマンドだけ見ると単純なんだけど、 Cocoapods のエラーとかで pod repo update が思い浮かず fvm flutter clean やったり derived data 消したり半日かかった。