Flutterでつまずいたことと解決
同期警告
ウィジェットのマウントを待たないといけない
if (!context.mounted) return;
iOS podfileが古い
Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.
To update the CocoaPods specs, run:
pod repo update
Error running pod install
Error launching application on iPhone 15.
Exited (1).
このようなものが出たらpodfile.lockを削除。再度実行すると依存関係を構築し直してくれる。
CocoaPodsの機能でパッケージのアップデートを行うことがiOS開発としては定石らしいがそれでは解決しない(DartがCocoaPodsを経由する都合?)
iOSプラグインのバージョン要件
Error: The plugin "google_maps_flutter_ios" requires a higher minimum iOS deployment version than your application is targeting.
To build, increase your application's deployment target to at least 14.0 as described at https://docs.flutter.dev/deployment/ios
Error running pod install
Error launching application on iPhone 15.
Exited (1).
リンク先のガイドは以下の通りだが、直らないときがある。
Xcodeを起動して
Runnerの設定を開き、iOS Deployment Targetを指定。ios/Flutter/AppFrameworkInfo.plistにあるMinimumOSVersionの設定も必要
その場合はios/Podfileのplatform :ios, '12.0'といった部分を変更しなければならない。(ファイル内コメントの通りこの行を無効化しても解決する。この場合のバージョンは?)
iOS FIrebaseパッケージのエラー
Swift Compiler Error (Xcode): Value of optional type '(any StorageProvider)?'
must be unwrapped to refer to member 'storage' of wrapped base type
'any StorageProvider'
`ios/Podfile`に`$FirebaseSDKVersion = '10.22.0'`などを追記。
このまま→https://zenn.dev/gen_kk/articles/bcc0a7ac47868c
Android APIレベル指定
Google Play デベロッパー プログラム ポリシーによりAndroid 14(API レベル 34) 以降を対象とする必要があるがpublic final int minSdkVersion = 21という記述になっており設定しないと対応できない。
flutter.minSdkなどを使いたいがSDKの変なところ: <SDK install folder>/flutter/packages/flutter_tools/gradle/src/main/groovy にある(参考 )が弄りたくないので都度android/app/buiid.gradleを指定。
Firestoreのオブジェクトに存在しないキーでアクセス
なぜかnullチェックするとI/flutter ( 6257): Bad state: field "property_name" does not exist within the DocumentSnapshotPlatformで失敗するので.data()['property_name']で呼び出し