谷歌flutter升級,谷歌的flutter

flutter項(xiàng)目升級2.0過程填坑記錄

在此之前先推薦看大佬的: 填坑指導(dǎo)

十多年的漢源網(wǎng)站建設(shè)經(jīng)驗(yàn),針對設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。成都全網(wǎng)營銷的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整漢源建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)從事“漢源網(wǎng)站設(shè)計(jì)”,“漢源網(wǎng)站推廣”以來,每個客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

iOS需要注意:

1、flutter2.0要求cocoapods 升級到1.9.0

詳情看這篇博客

2、原來flutter項(xiàng)目中的podfile文件是舊版本的ccocoapods了,刪除podfile和對應(yīng)的.lock,然后flutter項(xiàng)目重新運(yùn)行使用它自動生成的podfile文件

3、安裝CocoaPods

卸載cocoapods:sudo gem uninstall cocoapods

查看cocoapods版本:pod --version

指定版本安裝:

sudo gem install -n /usr/local/bin cocoapods -v 1.9.3(新MacOS系統(tǒng)升級)

不指定版本安裝

sudo gem install -n /usr/local/bin cocoapods

說明 :老項(xiàng)目sdk1.17.0===升級到2.0.1,當(dāng)前所有操作基于win平臺

到此為止環(huán)境已經(jīng)準(zhǔn)備妥當(dāng),正式進(jìn)入項(xiàng)目修改。

所有的插件都要適配到空安全,插件是否支持均會有對應(yīng)說明Null safety,適配過程不確定版本的話,可以使用dio: any,適配完事后再在pubspec.lock文件中查看具體的版本修改過來,實(shí)在有部分插件沒有支持的,參考下面

部分插件在適配空安全的版本放棄維護(hù)了,得自行更新或?qū)ふ姨娲?,如?flutter_swiper 變?yōu)?flutter_swiper_null_safety ,插件更新后要注意項(xiàng)目中的用法是否需要更新

2.1.1: 以前采用的是 provide 插件共享全局?jǐn)?shù)據(jù),現(xiàn)在變化為 provider ,用法改變, 點(diǎn)擊參考 ,以防文章丟失,我重復(fù)一遍:

比如:

2.1.2: dio版本升級到4.0.0最新版后,部分用法改變

2.2.1

2.2.2

解決方案:

2.2.3

解決方案:

2.2.4

解決方案:

2.2.5

解決方案:

2.2.6

解決方案:

2.2.7

解決方案:

2.2.8

解決方案: child 換為sliver

2.2.8.1

解決方案: 項(xiàng)目目錄下: android--app-build.gradle --minSdkVersion改為:18 或者19

2.2.8.2

解決方案: 在pubspec.yarm管理里面添加:publish_to

2.2.8.3

解決方案: video_player升級后字段發(fā)生了變化,initialized字段更換為:isInitialized(_controller.value.isInitialized)

2.2.8.4

解決方案:

2.2.8.5

解決方案:

2.2.8.6

解決方案: 方案一:刪除ios目錄下的Podfile.lock 文件然后重新運(yùn)行 pod install命令

方案二:刪除ios目錄下的Podfile.lock與Podfile文件 重新運(yùn)行flutter run或flutter build ios

方案三:刪除ios目錄,重新運(yùn)行 flutter create . 命令,注意有"."這個符號不要忘記

2.2.8.7

這個報錯一般對應(yīng)的就是下面的報錯,注意看后面的報錯信息,看是哪個插件報錯。

解決方案: 把Podfile的版本注釋打開,改為platform :ios, '9.0' 或者是更高的版本

全局替換

1.將new List() 替換為[];

2.TextField的inputFormatters:[WhitelistingTextInputFormatter.digitsOnly] 替換為[FilteringTextInputFormatter.digitsOnly]

3.TextField的inputFormatters:[WhitelistingTextInputFormatter(RegExp("[a-z|A-Z|0-9]"))]替換為FilteringTextInputFormatter.allow(RegExp("[a-z|A-Z|0-9]"))

4.Stack組件中overflow: Overflow.visible改為 clipBehavior: Clip.none;overflow: Overflow.clip改為clipBehavior:Clip.hardEdge

5.ListWheelScrollView組件中clipToSize = false改為clipBehavior: Clip.none,clipToSize = true改為 Clip.hardEdge

6.TextField中maxLengthEnforced: true改為maxLengthEnforcement:MaxLengthEnforcement.enforced

7.FlatButton、RaisedButton、OutlineButton的變化: 官方參考

顏色的屬性發(fā)生了變化,由原來的Color 變?yōu)榱薓aterialStatePropertyColor, 這是未了解決不同狀態(tài)(pressed、hovered、focused、disabled)下按鈕顏色的變化

例如

8.出現(xiàn)如下警告

9.showSnackBar報錯誤

解決方案: Scaffold換為ScaffoldMessenger

10.textSelectionColor棄用

解決方案:

11.charts_flutter升級后屬性報錯

解決方案:

12.flutter 真機(jī)調(diào)試無法訪問網(wǎng)絡(luò),dio報錯

解決方案:

android:

ios:

問題12完整參考

Flutter 升級空安全攻略

1、升級依賴的插件版本pubspec.yaml(包括example),pub get 解決依賴沖突

2、pubspec.yaml所在路徑下執(zhí)行 dart pub upgrade --null-safety 檢查是否所在flutter工程依賴庫是否都升級到了空安全版本

example示例需要進(jìn)入example路徑下檢查

1、List默認(rèn)構(gòu)造方法刪除,改用[];

main.dart文件main方法第一行增加CustomFlutterBinding();

2、flutter clean,刪除所有 pubspec.lock文件 ,pub get

3、FutureOr報錯引入頭文件、import 'dart:async';

4、屬性用優(yōu)先用late 或者 ?聲明,在確定不為空情況才用!

Flutter 項(xiàng)目升級報錯處理

1、flutter Warning: Podfile is out of date

Warning: Podfile is out of date This can cause a mismatched version of Flutter to be embedded in your app, which may result in App Store submission rejection or crashes. If you have local Podfile edits you would like to keep, see for instructions. To regenerate the Podfile, run: rm iOS/Podfile

2、Automatically assigning platform iOS with version 8.0 on target Runner 或者Automatically assigning platform iOS with version 12.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile

解決:只要修改ios目錄下podfile 第二行 去掉#號

原因是:沒有指定iOS版本。

3、 'AMapFoundation' uses the unencrypted 'http' protocol to transfer the Pod. Please be sure you're in a safe network with only trusted hosts. Otherwise, please reach out to the library author to notify them of this security issue.

類似的問題

解決方法:

登錄 尋找相關(guān)最新版本更新一下。

4、[!] An error occurred while processing the post-install hook of the Podfile.

undefined method `each_child' for #Dir:0x00007f8415636e38

Did you mean? each_slice

解決辦法:升級ruby

網(wǎng)頁題目:谷歌flutter升級,谷歌的flutter
標(biāo)題網(wǎng)址:http://muchs.cn/article10/pheodo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、網(wǎng)站導(dǎo)航域名注冊、靜態(tài)網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)、定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名