Android探路先鋒之Flutter
如下我匯入了一個WebView外掛
name: flutter_demo description: A new Flutter application.
dependencies: flutter: sdk: flutter
# The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.0 #如下我匯入了一個WebView外掛 flutter_webview_plugin: ^0.1.0+1
dev_dependencies: flutter_test: sdk: flutter pubspec.yaml 這個檔案相當 AS中的build.gradle
flutter packages get 這個就相當於在AS的Ctrl+9 編譯同步,需要在terminal中執行
pubspec.lock 生成對應的版本
flutter_webview_plugin: dependency: "direct main" description: name: flutter_webview_plugin url: "https://pub.dartlang.org" source: hosted version: "0.1.5" 提示熱修復無效 請在terminal鍵入R restart app
Some program elements were changed during reload but did not run when the view was reassembled; you may need to restart the app (by pressing "R") for the changes to have an effect. • _LaunchPage.doubleClick (package:flutter_demo/app/LaunchPage.dart:63) 資原始檔找不到異常 解決方法: 大神 何小有的 Blog:https://blog.csdn.net/hekaiyou/article/details/53204466 然後 記得 多flutter run幾次
D:\androidSpace\flutter_demo>flutter run Running "flutter packages get" in flutter_demo... Error on line 30, column 4 of pubspec.yaml: Expected a key while parsing a block mapping. assets: ^ pub get failed (65) 每次更新完flutterSDK都是一臉懵逼 解決 :https://github.com/flutter/flutter/wiki/Using-Flutter-in-China 配置環境變數
export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn C:\Users\Administrator>flutter Updating flutter tool... Got socket error trying to find package mockito at https://pub.dartlang.org. Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... 遠端蕩下來的專案 需要修改 local.properties 這個檔案引數 這三個都是需要手動配置的
sdk.dir=D:/android_sdk flutter.sdk=D:\\flutter flutter.buildMode=debug Finished with error: Please review your Gradle project setup in the android/ folder. * Error running Gradle: Exit code 1 from: F:\AndroidWorkSpace\Flutter_Gank\android\gradlew.bat app:properties:
FAILURE: Build failed with an exception.
* Where: Build file 'F:\AndroidWorkSpace\Flutter_Gank\android\build.gradle' line: 26
* What went wrong: A problem occurred evaluating root project 'android'. > A problem occurred configuring project ':app'. > The SDK directory 'D:\android_sdk' does not exist. 外部類不能以下劃線開始命名
error: The name '_Page' isn't a type so it can't be used as a type argument. (non_type_as_type_argument at [flutter_demo] lib\app\FirstPage.dart:16) 1 showSnackbar異常 Scaffold 賦 key 為_scaffoldKey 這個全域性變數即可
Scaffold.of(context).showSnackBar( new SnackBar(content: new Text(url))); ============================================================== final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); key: _scaffoldKey, _scaffoldKey.currentState.showSnackBar( new SnackBar(content: new Text(url))); --------------------- 作者:拍磚哥 來源:CSDN 原文:https://blog.csdn.net/qq_20330595/article/details/80004023 版權宣告:本文為博主原創文章,轉載請附上博文連結!