大佬教程收集整理的这篇文章主要介绍了Android探路先锋之Flutter - BUG集锦,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
name: Flutter_demo
description: A new Flutter application.
@H_616_21@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)
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)));
04-22 10:26:02.517 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: ══╡ EXCEPTION CAUGHT BY GEstuRE ╞═══════════════════════════════════════════════════════════════════
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: The following assertion was thrown while handling a gesture:
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: Scaffold.of() called with a context that does not contain a Scaffold.
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: No Scaffold ancestor Could be found starTing from the context that was passed to Scaffold.of(). This
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: usually happens when the context provided is from the same StatefulWidget as that whose build
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: function actually creates the Scaffold widget being sought.
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: There are several ways to avoid this problem. The simplest is to use a Builder to get a context that
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: is "under" the Scaffold. For an example of this,please see the documentation for Scaffold.of():
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: https://docs.Flutter.io/Flutter/material/Scaffold/of.html
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: A more efficient solution is to split your build function into several widgets. This introduces a
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: new context from which you can obtain the Scaffold. In this solution,you would have an outer widget
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: that creates the Scaffold populated by instances of your new inner widgets,and then in these inner
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: widgets you would use Scaffold.of().
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: A less elegant but more expedient solution is assign a GlobalKey to the Scaffold,then use the
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: key.currentState property to obtain the ScaffoldState rather than using the Scaffold.of() function.
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: The context used was:
04-22 10:26:02.521 24313-24371/com.xiaomakj.Flutterdemo I/Flutter: ImagePage
以上是大佬教程为你收集整理的Android探路先锋之Flutter - BUG集锦全部内容,希望文章能够帮你解决Android探路先锋之Flutter - BUG集锦所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。