升级Flutter2.10.4注意事项

image.png

下载新版本 官网

Flutter基本命令

flutter doctor 环境配置检查
flutter clean 清理flutter缓存
which flutter dart 查看当前flutter路径版本
export PATH=/Applications/flutter2.0/bin:$PATH 改变当前命令行flutter版本路径
flutter pub get 获取项目中flutter插件库
flutter pub outdated 查找项目中过时的依赖项(插件)

新安装步骤

在macOS上搭建Flutter开发环境

升级Flutter版本

更新步骤

@执行一下命令

flutter clean  //清理flutter缓存
which flutter dart  //查看当前flutter路径版本
export PATH=/Applications/flutter2.0/bin:$PATH  //改变当前命令行flutter版本路径
flutter pub get //更新项目的flutter插件库

遇见问题

一、插件库和dart版本不匹配

The current Dart SDK version is 2.13.4.                                                                                        
Because permission_handler_platform_interface 3.7.0 requires SDK version >=2.14.0 <3.0.0 and no versions of permission_handler_platform_interface match >3.7.0 <4.0.0, permission_handler_platform_interface ^3.7.0 is forbidden.
So, because dhbk depends on permission_handler 8.3.0 which depends on permission_handler_platform_interface ^3.7.0, version solving failed.

解决方法:
方法1.更改flutter版本或者确认Dart SDK 版本。
方法2.升级插件库。

//更改本地不同的flutter版本路径
export PATH=/Applications/flutter2.10.4/bin:$PATH

二、插件不支持新版本flutter

The plugin `simple_image_crop` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android
V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated
APIs.

解决方法:
更改插件。(替换simple_image_crop为ImageCropper)
三、找不到对应插件

Invalid plugin specification simple_image_crop. Cannot find the `flutter.plugin.platforms` key in the `pubspec.yaml` file. An instruction to format the `pubspec.yaml` can be found here:

解决方法:
更改插件。
四、flutter更新后写法变化

error: The method 'WhitelistingTextInputFormatter' isn't defined for the type 'TransferIntoFirstState4'. (undefined_method at [myApp] lib/page/transferInto/transfer_into_first_page4.dart:44)

解决方法:
更换写法。[FilteringTextInputFormatter.allow(RegExp("[0-9]"))]
五、flutter升级安全类型

The parameter ‘key’ can’t have a value of ‘null’ because of its type, but the implicit default value is ‘null’

解决方法:
方法1.添加required和?空安全类型
方法2.降低DartSDK版本

environment:
  sdk: ">=2.7.0 <3.0.0"

六、flutter升级后iOS系统权限失效
iOS系统权限需要配置permission_handler package
解决方法:
在iOS/podfile文件中添加配置信息

## dart: PermissionGroup.photos
'PERMISSION_PHOTOS=1',
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=1',
## dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=1',

七、pubspec.yaml插件版本或podfile三方库版本不改变
解决方法:
删除pubspec.lock或podfile.lock文件
flutter clean //清理flutter缓存
flutter pub get //重新获取项目中flutter插件库

https://www.jianshu.com/p/541864759294

你可能感兴趣的:(升级Flutter2.10.4注意事项)