
下載新版本 官網(wǎng)
Flutter基本命令
flutter doctor 環(huán)境配置檢查
flutter clean 清理flutter緩存
which flutter dart 查看當(dāng)前flutter路徑版本
export PATH=/Applications/flutter2.0/bin:$PATH 改變當(dāng)前命令行flutter版本路徑
flutter pub get 獲取項目中flutter插件庫
flutter pub outdated 查找項目中過時的依賴項(插件)
新安裝步驟
在macOS上搭建Flutter開發(fā)環(huán)境
升級Flutter版本
更新步驟
@執(zhí)行一下命令
flutter clean //清理flutter緩存
which flutter dart //查看當(dāng)前flutter路徑版本
export PATH=/Applications/flutter2.0/bin:$PATH //改變當(dāng)前命令行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版本或者確認(rèn)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)
三、找不到對應(yīng)插件
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系統(tǒng)權(quán)限失效
iOS系統(tǒng)權(quán)限需要配置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插件庫