共计 3554 个字符,预计需要花费 9 分钟才能阅读完成。
Flutter 开发从 0 到 1
今天开始又要下班了,你的假期工作实现如何啊?因为平时加班太多了,切实挤不出更多工夫,从开始想用 Flutter《Flutter 开发从 0 到 1(一)需要与筹备》写一个残缺的 APP 曾经过来三个月了,然而我没有遗记,这个国庆工夫我终于实现了。Flutter 的确弱小,不止跨平台,还反对桌面利用,包含 Window、macOS、Linux,以及 Web 利用,真正一套代码,全平台反对,野心可见一斑。
以上我尝试过了,打包成了 APK、macOS 桌面利用、Web 利用没问题,只能用两个字形容 Flutter:牛皮,明天先分享这个 APP 源码。
大体性能如下:
页面 | 知识点 | 成果预览 |
---|---|---|
框架 | 1、右滑菜单;2、我的珍藏 | |
博客列表 | 1、布局;2、ListView 下拉刷新好和加载更多 | |
博客详情 | 1、Markdown 渲染;2、代码高亮、3、膨胀 FloatingActionButton、4、珍藏 | |
评论列表 | 1、布局;2、评论 | |
账户 | 1、登录、2、注册 |
源码
公号「吴小龙同学」回复关键字“AndBlog”获取源码下载链接。
后续更新,这个链接都能够拜访,来,咱们一起持续探讨 Flutter。
如何运行
拿到源码,能够以 Web Server (web) 或 Chrome (web)运行代码,如果你是 MacBook Pro,你还能够以 iPhone 11 Pro Max (mobile)或 macOS (desktop)运行,运行到 Android 手机,开发的时候卡在了 Running Gradle task‘assembleDebug’…或者‘assembleRelease’,这里记录下,这时候个别在下载 Gradle 并配置我的项目,所以可能呈现的问题个别有两种:
报错一:
> Failed to apply plugin [id 'com.android.internal.version-check']
> Minimum supported Gradle version is 6.1.1. Current version is 5.6.2. If using the gradle wrapper, try editing the distributionUrl in /Users/wuxiaolong/AndroidStudioProjects/flutter_andblog/android/gradle/wrapper/gradle-wrapper.properties to gradle-6.1.1-all.zip
Gradle 目录 windows 个别在 C:\\Users\\ 用户名 \\.gradle\\
下,macOS 个别在/Users/ 用户名 /.gradle
下。
如果 Android Studio 开发,该门路能够在 ”File | Settings | Build, Execution, Deployment | Build Tools | Gradle” 中批改。
我应用的是“gradle-6.1.1”,能够在官网 https://gradle.org/releases/ 页面下载对应的“complete”安装包,放在 /Users/wuxiaolong/.gradle/wrapper/dists/gradle-6.1.1-all/cfmwm155h49vnt3hynmlrsdst
目录下即可。
报错二:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:desugarDebugFileDependencies'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not download arm64_v8a_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.jar (io.flutter:arm64_v8a_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7)
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/arm64_v8a_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.jar'.
> Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/arm64_v8a_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.jar'.
> Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.16, storage.googleapis.com/34.64.4.112, storage.googleapis.com/34.64.4.80] failed: connect timed out
> Could not download x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.jar (io.flutter:x86_debug:1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7)
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.jar'.
> Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7/x86_debug-1.0.0-ee76268252c22f5c11e82a7b87423ca3982e51a7.jar'.
> Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.16, storage.googleapis.com/34.64.4.112, storage.googleapis.com/34.64.4.80] failed: connect timed out
解决如下:
关上我的项目中 build.gradle 文件
buildscript {
repositories {//google()
//jcenter()
maven {url 'https://maven.aliyun.com/repository/google'}
maven {url 'https://maven.aliyun.com/repository/jcenter'}
maven {url 'http://maven.aliyun.com/nexus/content/groups/public'}
maven {url "http://download.flutter.io"}
}
dependencies {classpath 'com.android.tools.build:gradle:4.0.1'}
}
allprojects {
repositories {//google()
//jcenter()
maven {url 'https://maven.aliyun.com/repository/google'}
maven {url 'https://maven.aliyun.com/repository/jcenter'}
maven {url 'http://maven.aliyun.com/nexus/content/groups/public'}
maven {url "http://download.flutter.io"}
}
}