flutter運行之后報了這個錯,不能夠運行。

創(chuàng)新互聯(lián)建站是一家集網(wǎng)站建設(shè),靖西企業(yè)網(wǎng)站建設(shè),靖西品牌網(wǎng)站建設(shè),網(wǎng)站定制,靖西網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,靖西網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。
在結(jié)果上面會提示appt2等錯誤,其實錯誤的原因是Androidx支持有問題。
官方解決辦法: (合理打開)
app/build.gradle 下面
在gradle.properties下添加:
重新清理運行,ok。
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
1、升級依賴的插件版本pubspec.yaml(包括example),pub get 解決依賴沖突
2、pubspec.yaml所在路徑下執(zhí)行 dart pub upgrade --null-safety 檢查是否所在flutter工程依賴庫是否都升級到了空安全版本
example示例需要進入example路徑下檢查
1、List默認構(gòu)造方法刪除,改用[];
main.dart文件main方法第一行增加CustomFlutterBinding();
2、flutter clean,刪除所有 pubspec.lock文件 ,pub get
3、FutureOr報錯引入頭文件、import 'dart:async';
4、屬性用優(yōu)先用late 或者 ?聲明,在確定不為空情況才用!
Android V1 升級 V2
(1)舊版方法
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
(2)新方法:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
brew 安裝方式
通過gradle -v查看版本
在項目中的android/gradle/wrapper/gradle-wrapper.properties修改:
在andriod/build.gradle中找到buildscript并更新為新一點;
(在Andriod Studio 中會有提示適合的版本)
在android/build.gradle中添加阿里云的鏡像地址:
如果有用到其他的源請自行添加;
附上查詢阿里云源的鏡像地址
在android/app/build.gradle中修改compileSdkVersion:
(flutter run 后如果不適合會提示)
升級Flutter后, 最好(能不動就不動) 把需要的pub全部升級到最新
方法是去 找到對應(yīng)包的最新版本
然后更新:flutter pub get
tips:非必要真別升級,切記!切記!
如有用煩請看官點個贊
如有疑問可留言,會盡快的回復(fù)您
在此之前先推薦看大佬的: 填坑指導(dǎo)
iOS需要注意:
1、flutter2.0要求cocoapods 升級到1.9.0
詳情看這篇博客
2、原來flutter項目中的podfile文件是舊版本的ccocoapods了,刪除podfile和對應(yīng)的.lock,然后flutter項目重新運行使用它自動生成的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
說明 :老項目sdk1.17.0===升級到2.0.1,當(dāng)前所有操作基于win平臺
到此為止環(huán)境已經(jīng)準備妥當(dāng),正式進入項目修改。
所有的插件都要適配到空安全,插件是否支持均會有對應(yīng)說明Null safety,適配過程不確定版本的話,可以使用dio: any,適配完事后再在pubspec.lock文件中查看具體的版本修改過來,實在有部分插件沒有支持的,參考下面
部分插件在適配空安全的版本放棄維護了,得自行更新或?qū)ふ姨娲纾?flutter_swiper 變?yōu)?flutter_swiper_null_safety ,插件更新后要注意項目中的用法是否需要更新
2.1.1: 以前采用的是 provide 插件共享全局數(shù)據(jù),現(xiàn)在變化為 provider ,用法改變, 點擊參考 ,以防文章丟失,我重復(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
解決方案: 項目目錄下: 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 文件然后重新運行 pod install命令
方案二:刪除ios目錄下的Podfile.lock與Podfile文件 重新運行flutter run或flutter build ios
方案三:刪除ios目錄,重新運行 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 真機調(diào)試無法訪問網(wǎng)絡(luò),dio報錯
解決方案:
android:
ios:
問題12完整參考
網(wǎng)站標(biāo)題:升級flutter,升級鴻蒙后利弊
文章路徑:http://chinadenli.net/article32/dsgihsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、品牌網(wǎng)站設(shè)計、品牌網(wǎng)站建設(shè)、小程序開發(fā)、定制開發(fā)、企業(yè)網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)