迁移到 Flutter 2 失败

Ali*_*aXX 5 dart flutter

我有一个使用 Flutter 开发的项目v1.22.6并且运行良好,在将Flutter更新到v2.0.0并阅读文档后,我发现我可以dart migrate --apply-changes用来修复与 Flutter升级相关的问题,通过运行该命令,我得到了几十个错误,错误以:

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.
Run Code Online (Sandbox Code Playgroud)

将当前项目迁移到 v2 的最简单方法是什么?

小智 1

make sure you have following step by step migrate dart 2

and base on your error notification try to set in pubspec.yaml

environment:
  # Works in Dart 2 only.
  sdk: '>=2.0.0 <3.0.0'
Run Code Online (Sandbox Code Playgroud)