Flutter入门
Dart语言中文网 http://dart.goodev.org/
公司主营业务:做网站、网站制作、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出东乃免费做网站回馈大家。
Flutter官网 https://flutter.dev/
Flutter中文网 https://flutterchina.club/
一、windows环境搭建
配置镜像(加快FlutterSDK下载)
官方写的这个export是用在linux上的
export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
window上要将export换成set,但是去环境变量界面查看竟然没有
cmd 输入set,会查看所有的环境变量,发现有设置的环境变量。
下载FlutterSDK
下载FlutterSDK,在path里配置“flutter\bin”的环境变量。
执行flutter doctor,下载FlutterSDK相关的依赖。
Android Studio上安装Flutter和Dart插件
二、创建Flutter项目
创建项目
这里的flutter sdk path就是flutter文件夹位置
*****和创建Android APP项目对比可发现,没有了minSdk、targetSdk这些个选项。(意思)
运行项目
首次运行,可能会有以下错误:
Launching lib\main.dart on SM N9009 in debug mode... Initializing gradle... Finished with error: ProcessException: Process "F:\Work\Flutter\flutter_app\android\gradlew.bat" exited abnormally: Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. Exception in thread "main" javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Connection reset at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1551) at sun.security.ssl.AppInputStream.available(AppInputStream.java:60) at java.io.BufferedInputStream.available(BufferedInputStream.java:410) at sun.net.www.MeteredStream.available(MeteredStream.java:170) at sun.net.www.http.KeepAliveStream.close(KeepAliveStream.java:85) at java.io.FilterInputStream.close(FilterInputStream.java:181) at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.close(HttpURLConnection.java:3448) at org.gradle.wrapper.Download.downloadInternal(Download.java:77) at org.gradle.wrapper.Download.download(Download.java:44) at org.gradle.wrapper.Install$1.call(Install.java:61) at org.gradle.wrapper.Install$1.call(Install.java:48) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65) at org.gradle.wrapper.Install.createDist(Install.java:48) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) Caused by: javax.net.ssl.SSLException: java.net.SocketException: Connection reset at sun.security.ssl.Alerts.getSSLException(Alerts.java:208) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1916) at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1880) at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1825) at sun.security.ssl.AppInputStream.read(AppInputStream.java:116) at java.io.BufferedInputStream.read1(BufferedInputStream.java:284) at java.io.BufferedInputStream.read(BufferedInputStream.java:345) at sun.net.www.MeteredStream.read(MeteredStream.java:134) at java.io.FilterInputStream.read(FilterInputStream.java:133) at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3375) at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3368) at org.gradle.wrapper.Download.downloadInternal(Download.java:62) ... 7 more Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) at java.net.SocketInputStream.read(SocketInputStream.java:141) at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) at sun.security.ssl.InputRecord.readV3Record(InputRecord.java:593) at sun.security.ssl.InputRecord.read(InputRecord.java:532) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983) at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940) at sun.security.ssl.AppInputStream.read(AppInputStream.java:105) ... 14 more Command: F:\Work\Flutter\flutter_app\android\gradlew.bat -v
这个是在下载gradle,网络不好的原因。如果网络好了,run会自动下载gradle,run成功之后,控制台会显示:
Launching lib\main.dart on SM N9009 in debug mode... Initializing gradle... Resolving dependencies... [{"event":"app.progress","params":{"appId":"d62136c6-30c8-4426-8e6e-e1ec5bdf918e","id":"2","progressId":null,"message":"Running Gradle task 'assembleDebug'..."}}]Running Gradle task 'assembleDebug'... Built build\app\outputs\apk\debug\app-debug.apk. Installing build\app\outputs\apk\app.apk... [{"event":"app.progress","params":{"appId":"d62136c6-30c8-4426-8e6e-e1ec5bdf918e","id":"4","progressId":null,"message":"Syncing files to device SM N9009..."}}]Syncing files to device SM N9009...
赶紧体验了一把“热重载”特性,实在是非常爽!!!
另外,通过控制台日志可以发现:
Launching lib\main.dart on SM N9009 in debug mode... Initializing gradle... Resolving dependencies... Running Gradle task 'assembleDebug'... Built build\app\outputs\apk\debug\app-debug.apk. Installing build\app\outputs\apk\app.apk... Syncing files to device SM N9009...
项目第一次run的时候,也会生成apk文件。
打开项目出现一直提示加载的问题
Android Studio使用flutter upgrade等时提示waiting for another flutter command to release the startup lock
解决办法:
先打开任务管理器,结束掉所有dart.exe。然后打开你的flutter安装文件夹,找到\bin\cache中的lockfile文件删除。之后重启Android Studio。
依赖package
****更新yaml文件之后,点击Packages get,即可将包下载下来。
然后在dart里import
**** yaml文件,点击Get dependencies,会报下面的错误,不用管就行。
Working dir: F:\Work\Flutter\startup_namer G:\Android\flutter_windows_v1.7.8+hotfix.4-stable\flutter\bin\cache\dart-sdk\bin\pub.bat upgrade Resolving dependencies... Because startup_namer depends on flutter_test any from sdk which doesn't exist (the Flutter SDK is not available), version solving failed. Flutter users should run `flutter pub get` instead of `pub get`. Process finished with exit code 69
分享文章:Flutter入门
文章网址:http://abwzjs.com/article/iihepd.html