아카이브/Flutter
[Migration] Flutter 1.22.6에서 2.2.3으로 마이그레이션 하기
월담하는꼼티
2021. 7. 15. 15:06
마이그레이션 가이드 공식문서 참조
◆ Null Safety 업그레이드 가능한지 확인하기
1. Null Safety가 적용된 패키지 확인
dart pub outdated --mode=null-safety
- 현재 사용중인 패키지들에 null-safety가 적용되어 있는지 확인이 필요합니다.
- 사용 불가능한 패키지가 있다면, 대채가능한 다른 패키지로 교환하거나 포크를 하여 null-safety를 적용시켜야 됩니다.
◆ 마이그레이션 진행하기
1. 채널 확인
flutter channel
- bash 창에 flutter channel 입력 후 현재 Flutter SDK의 채널 확인
Flutter channels:
master
dev
beta
* stable
1.1 Stable이 아닐경우
flutter channel stable
- flutter channel stable 입력하여 stable로 채널 교체
2. Flutter 업그레이드
flutter upgrade
- 플러터 업그레이드 진행
2.1 Flutter 업그레이드 확인
flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale ko-KR)
• Flutter version 2.2.3 at /Users/***/Desktop/Flutter/flutter
• Framework revision f4abaa0735 (13 days ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
- 플러터 및 다트 버전확인
- 다트 버전이 2.12 이거나 그 이상인지 확인
2.2 VSCode 창 Reload
- 변경된 Dart, Flutter 반영하기 위해 리로드 해준다.
3. 패키지 업그레이드
dart pub upgrade --null-safety
- 패키지들을 null-safety 버전으로 업그레이드
Showing dependencies that are currently not opted in to null-safety.
[✗] indicates versions without null safety support.
[✓] indicates versions opting in to null safety.
All your dependencies declare support for null-safety.
- 이렇게 나오면 업그레이드가 무사히 완료
4. 마이그레이션
dart migrate
- 오류가 발생했을 시, 해당 오류를 무시하고 진행할 수 있는 명령어 옵션이 나온다.
See https://dart.dev/go/null-safety-migration for a migration guide.
Analyzing project...
[---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]
No analysis issues found.
Generating migration suggestions...
[---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]
Compiling instrumentation information...
[---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]
View the migration suggestions by visiting:
http://127.0.0.1:...
Use this interactive web view to review, improve, or apply the results.
When finished with the preview, hit ctrl-c to terminate this process.
If you make edits outside of the web view (in your IDE), use the 'Rerun from
sources' action.
- 아래의 주소창[http://127.0.0.1:...]으로 들어가면 파일별로 마이그레이션이 적용되는 부분이 보이며 마이그레이션 도구를 활용하여 수정할 수 있다.
- 크롬으로 접속을 권장한다.
- 우측 상단의 APPLY MIGRATION을 눌러 마이그레이션 적용