Open4

Flutter2 Dart Null Safety移行

takamasa.mizukamitakamasa.mizukami
$ flutter --version
Flutter 1.22.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7891006299 (5 months ago)2020-12-10 11:54:40 -0800
Engine • revision ae90085a84
Tools • Dart 2.10.4

takamasa.mizukamitakamasa.mizukami
$ flutter channel
Flutter channels:
  master
  dev
  beta
* stable
$ flutter upgrade

Flutter 2.0.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1d9032c7e1 (23 hours ago)2021-04-29 17:37:58 -0700
Engine • revision 05e680e202
Tools • Dart 2.12.3

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 2.0.6, on Mac OS X 10.15.6 19G73 darwin-x64, locale ja-JP)
[] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[!] Xcode - develop for iOS and macOS
    ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[] Chrome - develop for the web
[] Android Studio (version 4.0)
[!] IntelliJ IDEA Ultimate Edition (version 2016.2.4)
    ✗ This install is older than the minimum recommended version of 2017.1.0.
[] VS Code (version 1.30.0)
[] Connected device (2 available)
$ pod --version
1.9.3
$ gem install cocoapods
Fetching: activesupport-5.2.5.gem (100%)
Successfully installed activesupport-5.2.5
Fetching: public_suffix-4.0.6.gem (100%)
Successfully installed public_suffix-4.0.6
Fetching: addressable-2.7.0.gem (100%)
Successfully installed addressable-2.7.0
Fetching: cocoapods-core-1.10.1.gem (100%)
Successfully installed cocoapods-core-1.10.1
Fetching: xcodeproj-1.19.0.gem (100%)
Successfully installed xcodeproj-1.19.0
Fetching: cocoapods-1.10.1.gem (100%)
Successfully installed cocoapods-1.10.1
Parsing documentation for activesupport-5.2.5
Installing ri documentation for activesupport-5.2.5
Parsing documentation for public_suffix-4.0.6
Installing ri documentation for public_suffix-4.0.6
Parsing documentation for addressable-2.7.0
Installing ri documentation for addressable-2.7.0
Parsing documentation for cocoapods-core-1.10.1
Installing ri documentation for cocoapods-core-1.10.1
Parsing documentation for xcodeproj-1.19.0
Installing ri documentation for xcodeproj-1.19.0
Parsing documentation for cocoapods-1.10.1
Installing ri documentation for cocoapods-1.10.1
Done installing documentation for activesupport, public_suffix, addressable, cocoapods-core, xcodeproj, cocoapods after 11 seconds
6 gems installed
$ pod --version
1.10.1

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 2.0.6, on Mac OS X 10.15.6 19G73 darwin-x64, locale ja-JP)
[] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[] Xcode - develop for iOS and macOS
[] Chrome - develop for the web
[] Android Studio (version 4.0)
[!] IntelliJ IDEA Ultimate Edition (version 2016.2.4)
    ✗ This install is older than the minimum recommended version of 2017.1.0.
[] VS Code (version 1.30.0)
[] Connected device (2 available)

! Doctor found issues in 1 category.

flutter プロジェクトに移動

$ cd /your_flutter_project
$ dart pub outdated --mode=null-safety
  ╔════════════════════════════════════════════════════════════════════════════╗
  ║ The Dart tool uses Google Analytics to anonymously report feature usage    ║
  ║ statistics and to send basic crash reports. This data is used to help      ║
  ║ improve the Dart platform and tools over time.                             ║
  ║                                                                            ║
  ║ To disable reporting of anonymous analytics, run:                          ║
  ║                                                                            ║
  ║   dart --disable-analytics                                                 ║
  ║                                                                            ║
  ╚════════════════════════════════════════════════════════════════════════════╝

Showing dependencies that are currently not opted in to null-safety.
[] indicates versions without null safety support.
[] indicates versions opting in to null safety.

Package Name            Current    Upgradable  Resolvable           Latest               

direct dependencies:   
cloud_firestore         ✗0.16.0+1  ✗0.16.0+1   ✓1.0.7               ✓1.0.7               
cupertino_icons         ✗0.1.3     ✗0.1.3      ✓1.0.2               ✓1.0.2               
firebase_analytics      ✗7.0.1     ✗7.0.1      ✓8.0.2               ✓8.0.2               
firebase_crashlytics    ✗0.4.0+1   ✗0.4.0+1    ✓2.0.2               ✓2.0.2               
firebase_performance    ✗0.5.0+1   ✗0.5.0+1    ✓0.7.0+2             ✓0.7.0+2             
geoflutterfire          ✗2.2.2     ✗2.2.2      ✓3.0.0-nullsafety.2  ✓3.0.0-nullsafety.2  
geolocator              ✗6.2.1     ✗6.2.1      ✓7.0.3               ✓7.0.3               
google_maps_flutter     ✗1.2.0     ✓2.0.3      ✓2.0.3               ✓2.0.3               
share                   ✗0.6.5+4   ✓2.0.1      ✓2.0.1               ✓2.0.1               
shared_preferences      ✗0.5.12+4  ✓2.0.5      ✓2.0.5               ✓2.0.5               
url_launcher            ✗5.7.10    ✓6.0.3      ✓6.0.3               ✓6.0.3               

dev_dependencies:      
flutter_launcher_icons  ✗0.8.1     ✓0.9.0      ✓0.9.0               ✓0.9.0               
flutter_native_splash   ✗0.3.2     ✓1.1.8+4    ✓1.1.8+4             ✓1.1.8+4             
pedantic_mono           ✗1.10.0+4  ✓1.11.0+2   ✓1.11.0+2            ✓1.12.0-dev          

7 upgradable dependencies are locked (in pubspec.lock) to older versions.
To update these dependencies, use `dart pub upgrade`.

7  dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
$ dart pub upgrade --null-safety
Resolving dependencies... (3.3s)

***

Changed 14 constraints in pubspec.yaml:
  cloud_firestore: any -> ^1.0.7
  firebase_analytics: any -> ^8.0.2
  firebase_crashlytics: any -> ^2.0.2
  firebase_performance: any -> ^0.7.0+2
  geolocator: any -> ^7.0.3
  google_maps_flutter: any -> ^2.0.3
  shared_preferences: any -> ^2.0.5
  url_launcher: any -> ^6.0.3
  geoflutterfire: any -> ^3.0.0-nullsafety.2
  share: any -> ^2.0.1
  cupertino_icons: ^0.1.3 -> ^1.0.2
  pedantic_mono: any -> ^1.11.0+2
  flutter_launcher_icons: any -> ^0.9.0
  flutter_native_splash: any -> ^1.1.8+4
Running pod install...
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `cloud_firestore` from `.symlinks/plugins/cloud_firestore/ios`
    cloud_firestore: Using Firebase SDK version '7.11.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_analytics` from `.symlinks/plugins/firebase_analytics/ios`
    firebase_analytics: Using Firebase SDK version '7.11.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
    firebase_core: Using Firebase SDK version '7.11.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_crashlytics` from `.symlinks/plugins/firebase_crashlytics/ios`
    firebase_crashlytics: Using Firebase SDK version '7.11.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_performance` from `.symlinks/plugins/firebase_performance/ios`
    firebase_performance: Using Firebase SDK version '7.11.0' defined in 'firebase_core'
    -> Fetching podspec for `geolocator` from `.symlinks/plugins/geolocator/ios`
    -> Fetching podspec for `google_maps_flutter` from `.symlinks/plugins/google_maps_flutter/ios`
    -> Fetching podspec for `share` from `.symlinks/plugins/share/ios`
    -> Fetching podspec for `shared_preferences` from `.symlinks/plugins/shared_preferences/ios`
    -> Fetching podspec for `url_launcher` from `.symlinks/plugins/url_launcher/ios`

    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_0_3_5.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/7.5.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: all_pods_versions_a_d_d.txt exists! Returning local because checking is only perfomed in repo update
      CDN: trunk Relative path: Specs/a/d/d/GoogleMaps/4.1.0/GoogleMaps.podspec.json exists! Returning local because checking is only perfomed in repo update
    [!] CocoaPods could not find compatible versions for pod "Firebase/Performance":
      In Podfile:
        firebase_performance (from `.symlinks/plugins/firebase_performance/ios`) was resolved to 0.7.0-2, which depends on
          Firebase/Performance (= 7.11.0)

    None of your spec sources contain a spec satisfying the dependency: `Firebase/Performance (= 7.11.0)`.

    You have either:
     * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
     * mistyped the name or version.
     * not added the source repo that hosts the Podspec to your Podfile.

    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:257:in `process_topmost_state'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/resolver.rb:94:in `resolve'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1074:in `block in resolve_dependencies'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/bin/pod:23:in `load'
    /Users/mizukamitakamasa/.rbenv/versions/2.5.0/bin/pod:23:in `<main>'

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 12 Pro Max.
$ pod repo update
Updating spec repo `master`
  $ /usr/local/bin/git -C /Users/mizukamitakamasa/.cocoapods/repos/master fetch origin --progress
  remote: Enumerating objects: 196309, done.        
  remote: Counting objects: 100% (62481/62481), done.        
  remote: Compressing objects: 100% (5142/5142), done.        
  remote: Total 196309 (delta 57507), reused 61455 (delta 56987), pack-reused 133828        
  Receiving objects: 100% (196309/196309), 24.73 MiB | 8.09 MiB/s, done.
  Resolving deltas: 100% (135723/135723), completed with 8753 local objects.
  From https://github.com/CocoaPods/Specs
     1af19e932b3b..0db06a29f0f3  master     -> origin/master
  $ /usr/local/bin/git -C /Users/mizukamitakamasa/.cocoapods/repos/master rev-parse --abbrev-ref HEAD
  master
  $ /usr/local/bin/git -C /Users/mizukamitakamasa/.cocoapods/repos/master reset --hard origin/master
  Updating files: 100% (20321/20321), done.
  HEAD is now at 0db06a29f0f3 [Add] GoogleMobileAdsMediationFyber 7.8.1.0
Updating spec repo `trunk`

Running pod install...
    [!] An error occurred while processing the post-install hook of the Podfile.

    undefined method `each_child' for #<Dir:0x00007f8c37b862d8>
    Did you mean?  each_slice

https://stackoverflow.com/questions/65197799/flutter-pod-install-problem-undefined-method-each-child-for-dir0x00007fa6

$ rbenv install -l
2.5.8
2.6.6
2.7.1
jruby-9.2.13.0
maglev-1.0.0
mruby-2.1.2
rbx-5.0
truffleruby-20.2.0
truffleruby+graalvm-20.2.0
$ ruby --version
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin19]

$ rbenv install 2.7.1
Downloading openssl-1.1.1g.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46
Installing openssl-1.1.1g...
Installed openssl-1.1.1g to /Users/mizukamitakamasa/.rbenv/versions/2.7.1

Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
ruby-build: using readline from homebrew
Installed ruby-2.7.1 to /Users/mizukamitakamasa/.rbenv/versions/2.7.1

$ rbenv global 2.7.1
$ ruby --version
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]

$ gem install cocoapods

$ pod --version
1.10.1

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 2.0.6, on Mac OS X 10.15.6 19G73 darwin-x64, locale ja-JP)
[] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[] Xcode - develop for iOS and macOS
[] Chrome - develop for the web
[] Android Studio (version 4.0)
[!] IntelliJ IDEA Ultimate Edition (version 2016.2.4)
    ✗ This install is older than the minimum recommended version of 2017.1.0.
[] VS Code (version 1.30.0)
[] Connected device (2 available)

! Doctor found issues in 1 category.

$ dart migrate