在此之前先推薦看大佬的: 填坑指導(dǎo)
成都創(chuàng)新互聯(lián)專注于企業(yè)成都全網(wǎng)營銷推廣、網(wǎng)站重做改版、潁東網(wǎng)站定制設(shè)計、自適應(yīng)品牌網(wǎng)站建設(shè)、H5響應(yīng)式網(wǎng)站、商城網(wǎng)站建設(shè)、集團公司官網(wǎng)建設(shè)、成都外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計等建站業(yè)務(wù),價格優(yōu)惠性價比高,為潁東等各大城市提供網(wǎng)站開發(fā)制作服務(wù)。
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完整參考
1 File-New Flutter Project -Flutter-next選擇 project type(Android studio不同版本會有所差異)
參考鏈接:
2.1本地引入
這里plugin是flutter module引入使用,如果想project引用其實可以直接在.android下面創(chuàng)建插件
2.2遠程引用
You are building a fat APK that includes binaries for android-arm, android-arm64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
? ? flutter build appbundle --target-platform android-arm,android-arm64
? ? Learn more on:
To split the APKs per ABI, run:
? ? flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
? ? Learn more on:?
Initializing gradle...? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2.3s
Resolving dependencies...? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 14.2s
Running Gradle task 'assembleRelease'...? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?: E:\work_tool\flutter\.pub-cache\hosted\pub.flutter-io.cn\connectivity-0.4.4\android\src\main\java\io\flutter\plugins\connectivity\ConnectivityPlugin.java???????????????? API??
?: ?й???????, ????? -Xlint:deprecation ???±???
?: E:\work_tool\flutter\.pub-cache\hosted\pub.flutter-io.cn\url_launcher-5.1.3\android\src\main\java\io\flutter\plugins\urllauncher\WebViewActivity.java?
??????????????? API??
?: ?й???????, ????? -Xlint:deprecation ???±???
Calling mockable JAR artifact transform to create file: C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\android.jar\baf414ed95f14e507d85c560886dfbe2\android.jar with input E:\work_tool\sdk\android-sdk-windows\platforms\android-28\android.jar
Calling mockable JAR artifact transform to create file: C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\android.jar\ab096bb3fb172ccb785acdb1058c10a9\android.jar with input E:\work_tool\sdk\android-sdk-windows\platforms\android-27\android.jar
Request to incrementing alive workforce from 0. Current workforce (dead or alive) 0
thread-pool size=4
ProGuard, version 6.0.3
Reading input...
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\flutter.jar\ab2691c929f4d2aa57a17fa551e662a6\jetified-flutter.jar] (filtered)
Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\app\intermediates\flutter\release\libs.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\localbroadcastmanager-1.0.0.aar\7a407f962902eada026a8e241a760bac\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\work-runtime-2.1.0.aar\8e3a1e8a8ff79006a94df6c01ceeb4f5\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\fragment-1.1.0.aar\4fa7d1b49e3514cb08c8a696f9b59436\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\room-runtime-2.1.0.aar\1b8774fa39759f08defb930275652eac\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\room-runtime-2.1.0.aar\1b8774fa39759f08defb930275652eac\jars\libs\room-common-java8-2.1.0.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\viewpager-1.0.0.aar\885186e7f6f969363bc93cd607d741a5\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\loader-1.0.0.aar\f84f22ad0a97d2c689850b912fc04277\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\activity-1.0.0.aar\a46db1490fae1b9001fc672a24eb288f\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\customview-1.0.0.aar\fe8bf4a709414e884086911d2168b715\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\core-1.1.0.aar\87febb54759dd5a2c7be8e971d745644\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\versionedparcelable-1.1.0.aar\754157c6f50ca4e4cf3ac8d7cb5ced26\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.collection\collection\1.1.0\1f27220b47669781457de0d600849a5de0e89909\collection-1.1.0.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-livedata-2.0.0.aar\de6944801d37d99b1dd0b877649fde1f\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-livedata-core-2.0.0.aar\e21d6663beb6faa41a30fd5a582cb4d9\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\core-runtime-2.0.1.aar\724bb0cc2ce99eaf0a23a99bb1cc5c23\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.room\room-common\2.1.0\b87765704590bd992ea0d92ac50253a9df7818a0\room-common-2.1.0.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\sqlite-framework-2.0.1.aar\9cbdf82e938f7e565620a3682d2406e9\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\sqlite-2.0.1.aar\1215aa5476f752bd431fb2d8059a1a39\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-service-2.0.0.aar\9d24ebd4d6766d7b2cd515369a737934\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-runtime-2.1.0.aar\ca02c0867547ae607130bcc54a4a9ba5\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-viewmodel-2.1.0.aar\594e1ff6298a01d8933530bb534fa472\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\savedstate-1.0.0.aar\8a2c3791a34fc80e5d9d268bf2886f95\jars\classes.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.lifecycle\lifecycle-common\2.1.0\c67e7807d9cd6c329b9d0218b2ec4e505dd340b7\lifecycle-common-2.1.0.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.arch.core\core-common\2.1.0\b3152fc64428c9354344bd89848ecddc09b6f07e\core-common-2.1.0.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation\1.1.0\e3a6fb2f40e3a3842e6b7472628ba4ce416ea4c8\annotation-1.1.0.jar] (filtered)
Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\com.google.guava\listenablefuture\1.0\c949a840a6acbc5268d088e47b04177bf90b3cad\listenablefuture-1.0.jar] (filtered)
Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\flutter_downloader\intermediates\intermediate-jars\release\classes.jar] (filtered)
Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\shared_preferences\intermediates\intermediate-jars\release\classes.jar] (filtered)
Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\url_launcher\intermediates\intermediate-jars\release\classes.jar] (filtered)
Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\sqflite\intermediates\intermediate-jars\release\classes.jar] (filtered)
Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\connectivity\intermediates\intermediate-jars\release\classes.jar] (filtered)
Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\path_provider\intermediates\intermediate-jars\release\classes.jar] (filtered)
Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\package_info\intermediates\intermediate-jars\release\classes.jar] (filtered)
Reading program directory [F:\dartSpace\flutter\jiddspace\nfc\build\app\intermediates\javac\release\compileReleaseJavaWithJavac\classes] (filtered)
Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\app\intermediates\transforms\mergeJavaRes\release\0.jar] (filtered)
Reading library jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation\1.0.0\45599f2cd5965ac05a1488fa2a5c0cdd7c499ead\annotation-1.0.0.jar] (filtered)
Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\android.jar]
Reading library jar [E:\work_tool\sdk\android-sdk-windows\build-tools\28.0.3\core-lambda-stubs.jar]
Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\optional\org.apache.http.legacy.jar]
Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\optional\android.test.mock.jar]
Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\optional\android.test.base.jar]
Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\optional\android.test.runner.jar]
Initializing...
Warning: io.flutter.embedding.android.FlutterView: can't find referenced method 'android.graphics.Insets getSystemGestureInsets()' in library class android.view.WindowInsets
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.view.FlutterView: can't find referenced method 'android.graphics.Insets getSystemGestureInsets()' in library class android.view.WindowInsets
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
Note: io.flutter.view.AccessibilityViewEmbedder$ReflectionAccessors: can't find dynamically referenced class android.util.LongArray
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
Note: there were 1 unresolved dynamic references to classes or interfaces.
? You should check if you need to specify additional program jars.
? ()
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
Thread(Tasks limiter_1): destruction
Warning: there were 12 unresolved references to classes or interfaces.
? ? You may need to add missing library jars or update their versions.
? ? If your code works fine without the missing classes, you can suppress
? ? the warnings with '-dontwarn' options.
? ? ()
Warning: there were 2 unresolved references to library class members.
? ? You probably need to update the library versions.
? ? ()
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
Job failed, see logs for details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at
BUILD FAILED in 4m 23s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done? ? ? ? ? ? ? ? ? ? 264.4s (!)
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
在原生開發(fā)中, Android 使用 Gradle 來管理依賴, iOS 用 Cocoapods 來管理依賴,Node 中通過 npm來管理依賴。 Flutter 使用配置文件 pubspec.yaml (位于項目根目錄)來管理第三方依賴包。
Pub 是Google官方的Dart Packages倉庫,類似于node中的npm倉庫,android中的jcenter,我們可以在上面查找我們需要的包和插件,也可以向pub發(fā)布我們的包和插件。
Pub工具 包含管理Package、部署Package和部署命令行應(yīng)用的命令。
如果使用的是Flutter SDK,不要直接使用pub命令。而是使用flutter pub命令,如下:
命令pub get/upgrade/outdated 屬于管理Package的依賴關(guān)系
用于檢索當(dāng)前 Package 所依賴的其它 Package。如果 pubspec.lock 文件已經(jīng)存在,則根據(jù)該文件中保存的依賴項版本獲取對應(yīng)的依賴項。如有必要,將會創(chuàng)建或更新該文件。
更新 package 依賴
當(dāng)你添加一個 package 后首次運行 flutter pub get, Flutter 將會保存在 pubspec.lock lockfile 中找到的具體 package 版本。這將確保當(dāng)你或者團隊中其他開發(fā)者運行 flutter pub get 后能得到相同版本的 package。
如果你想升級到 package 的最新版本,比如使用 package 的最新特性,請運行 flutter pub upgrade 。這將檢索你在 pubspec.yaml 文件中指定的版本約束所允許的最高可用版本。
案例
在flutter項目中導(dǎo)入hive包,在pubspec.yaml文件中添加配置:
執(zhí)行flutter pub get,可以在 pubspec.lock 中看到 hive 版本是2.1.0,這是因為目前hive的最新版本是2.1.0,配置“^”表示向最新版本兼容,具體可查看Package版本管理( ),所以再執(zhí)行flutter pub upgrade 可以看到版本還是2.1.0,這個時候會發(fā)現(xiàn)pub get和 pub upgrade 效果一樣。
但是未來如果 hive 發(fā)布了2.2.0版本,這個時候使用flutter pub get在pubspec.lock中看到hive版本依舊是2.1.0,而執(zhí)行flutter pub upgrade 后在pubspec.lock中看到hive版本就是2.2.0。
現(xiàn)在先在flutter 項目的pubspec.yaml文件添加配置,指定hive版本是2.0.5,如下:
這個時候執(zhí)行flutter pub get后,可以在pubspec.lock的文件中看到hive版本是2.0.5,如果這個時候更改配置為 hive: ^2.0.5,再執(zhí)行flutter pub get就會發(fā)現(xiàn)在pubspec.lock的文件中看到hive版本還是2.0.5,這個時候可以執(zhí)行flutter pub outdated查看依賴的每個 package,如下圖,
可以看到,Upgrable項hive版本號為2.1.0,執(zhí)行flutter pub upgrade 后可以看到在pubspec.lock的文件中看到hive版本是2.1.0
在pubspec.yaml文件添加配置:
lxx_package_demo信息如下圖:
執(zhí)行flutter pub get后在pubspec.lock中看到flutter_log版本是0.0.1
現(xiàn)在修改lxx_package_demo版本號為0.0.2,再執(zhí)行flutter pub get
會發(fā)現(xiàn)版本會及時更新為0.0.2,這個時候執(zhí)行flutter pub get/upgrade效果一樣
參考文檔:
我是初學(xué)者小白,所以很多看法不深,理解也不夠透徹。但是很適合小白們一起從低角度往高處探索。文中有錯誤的,感謝指正,一起進步。
趁著假期做一個Flutter的地圖功能,因為后端選用了百度地圖,所以前端沒得挑。找了遍插件,并沒有現(xiàn)成可用的。(不過發(fā)現(xiàn)了百度官方也自開發(fā)Flutter插件,目前功能只有一個獲取本地位置信息,后期會繼續(xù)增加吧?很期待?。?/p>
參考帖子:
這個實際上跟功能之間沒太大關(guān)系,只是我按照個人摸索的過程來寫。
當(dāng)對一個“領(lǐng)域/知識塊”完全不懂的時候,360°的方向都不確定的話。先了解基礎(chǔ)概念,有利于你確定自己的摸索方向。
參考帖子:
中間我跳過了幾十,上百個帖子的摸索過程。這個才是關(guān)鍵能夠真正做事的參考。
因為百度的sdk還算是很完善的,所以一旦出問題,都會有對應(yīng)的報錯提示。
我是使用flutter插件:permission_handler,來解決安卓的動態(tài)授權(quán)問題,用法簡單而且設(shè)計合理。
這個錯誤直接來看,就是簽名有問題。怎么查看SHA1碼和包名,這里不多說,網(wǎng)上有極其多的方法,百度Sdk開發(fā)指南里也有。沒那么復(fù)雜,也沒那么麻煩。按照流程操作就是對的。
實在不放心?跟我一樣,flutter打包后,把apk反過來解SHA1碼不就行了?
參考帖子:
紅色框框基本就是帖子講解的那樣。
藍色框框見下圖:release標簽里好像是自己設(shè)置了。所以debug標簽里面,箭頭指向的位置,是我多設(shè)置的一個參數(shù)。
uid: -1 appid -1 msg: httpsPost failed,IOException:Unable to resolve host "api.map.baidu.com": No address associated with hostname
這一步我是哭笑不得,一開始老是和問題(2)混淆,導(dǎo)致浪費很多時間。仔細閱讀后,發(fā)現(xiàn)是不能連接到“api.map.baidu.com”。
我打開模擬器的chrome瀏覽器,發(fā)現(xiàn)不能上網(wǎng)。查看手機的dns是10.0.2.3(默認的),和家里wifi不一樣,所以不能上網(wǎng)也正常,之前居然沒發(fā)現(xiàn)這個問題!?。?/p>
終端執(zhí)行:adb shell? 和? getprop,就可以查看所有的屬性參數(shù)了。(window小伙伴自行百度,這個沒多大差別。如果你有多個設(shè)備,記得自己選好設(shè)備。)
在里面找到這一項,就是你的dns參數(shù)。有些人是net.dns1,我的是net.eth0.dns1。這個沒關(guān)系,只是等下指令 稍微改動 就行。
修改dns指令:setprop net.eth0.dns1 192.168.2.1
后面的192.168.2.1是我自己的dns,這個根據(jù)自己的情況來填寫。不懂的百度下怎么查看自己的dns。
雖然提示設(shè)置失敗,但是回到模擬器一看,地圖已經(jīng)顯示出來了。
嘿嘿,在flutter設(shè)定多大的區(qū)域,地圖就是多大的區(qū)域。用起來就很方便了。
過程十分痛苦,因為對flutter不是很熟悉,對Android原生更是了解很少。所以自己就像突然不能講話,被丟到一個陌生的環(huán)境,卻要我去找一個人。所以細心很重要,一定要看清楚錯誤提示,不要錯過每一個細節(jié)和可能性。
幸好最后解決了問題,開心~
其實如果你仔細閱讀過百度官方的文檔,會發(fā)現(xiàn)里面有關(guān)于 地圖的生命周期管理 。然后在這里面沒有提及到,這一點雖然沒提,但不可或缺,小伙伴就自行思考吧。
最后還有一點,其實我的初衷是想實現(xiàn)一個百度地圖的plugin,但是苦于能力有限,對Android的不熟悉,最后折戟。我不得已另起項目,然后重新實現(xiàn)地圖sdk接入。經(jīng)過這次對于這些有更多更全面的認知后,有空會再次研究flutter 插件的開發(fā),共勉,奧利給?。?!
當(dāng)前文章:flutter2.1,flutter210鍵盤問題
鏈接地址:http://aaarwkj.com/article38/dsigssp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、面包屑導(dǎo)航、自適應(yīng)網(wǎng)站、網(wǎng)站設(shè)計公司、網(wǎng)頁設(shè)計公司、微信公眾號
聲明:本網(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)