'flutter migration to null-safety - Bad state: Error: package has unmigrated dependencies - own screens
I try to migrate a flutter project to null-safety. I get the feedback that all packages are compatible and upgrated. When I run dart migrate, my own writen screens (which I want to migrate) are criticized as unmigrated dependencies.
1)
$ dart pub outdated --mode=null-safety
Resolving...
Showing dependencies that are currently not opted in to null-safety.
[x] indicates versions without null safety support.
[+] indicates versions opting in to null safety.
Computing null safety support...
All your dependencies declare support for null-safety.
$ dart pub upgrade --null-safety
...
dio: ^4.0.5-beta1 -> ^4.0.4
firebase_core: ^1.11.0 -> ^1.12.0
$ dart pub get
...
Got dependencies!
$ dart migrate
Analyzing project...
[-------------------------------------------------/]
Bad state: Error: package has unmigrated dependencies.
Before migrating your package, we recommend ensuring that every library it
imports (either directly or indirectly) has been migrated to null safety, so
that you will be able to run your unit tests in sound null checking mode. You
are currently importing the following non-null-safe libraries:
package:prosz/Screens/bottombar/tabbar.dart
package:prosz/Screens/chat.dart
package:brosz/Screens/chatPost.dart
...
Please upgrade the packages containing these libraries to null safe versions
before continuing. To see what null safe package versions are available, run
the following command: `dart pub outdated --mode=null-safety`.
To skip this check and try to migrate anyway, re-run with the flag
`--skip-import-check`.
versions
$ flutter --version
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (7 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1
pubspec
environment:
sdk: ">=2.1.0 <3.0.0"
changing pubspec to sdk: ">=2.12.0 <3.0.0" fixes the problem, but causes:
311 analysis issues found
.....
The migration tool didn't start, due to analysis errors.
The following steps might fix your problem:
1. Set the lower SDK constraint (in pubspec.yaml) to a version before 2.12.
2. Run `dart pub get`.
3. Try running `dart migrate` again.
Solution 1:[1]
Change 2.1.0 to 2.12.0 in your pubspec
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stijn2210 |
