博客
关于我
Flutter 开发从 0 到 1(五)源码
阅读量:404 次
发布时间:2019-03-06

本文共 3758 字,大约阅读时间需要 12 分钟。

Flutter 开发从 0 到 1

明天开始又要上班了,你的假期任务完成如何啊?由于平时加班太多了,实在挤不出更多时间,从开始想用 Flutter 写一个完整的 APP 已经过去三个月了,但是我没有忘记,这个国庆时间我终于完成了。Flutter 确实强大,不止跨平台,还支持桌面应用,包括 Window、macOS、Linux,以及 Web 应用,真正一套代码,全平台支持,野心可见一斑。

以上我尝试过了,打包成了 APK、macOS 桌面应用、Web 应用没问题,只能用两个字形容 Flutter:牛皮,今天先分享这个 APP 源码。

大体功能如下:

框架:右滑菜单;我的收藏

博客列表:布局;ListView 下拉刷新好和加载更多

博客详情:Markdown 渲染;代码高亮、收缩 FloatingActionButton、收藏

评论列表:布局;评论

账户:登录、注册

公号「吴小龙同学」回复关键字「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" ,可以在官网 页面下载对应的 "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" }
}

}

转载地址:http://qhckz.baihongyu.com/

你可能感兴趣的文章
OA系统选型:选择好的工作流引擎
查看>>
OA让企业业务流程管理科学有“据”
查看>>
OA项目之会议通知(查询&是否参会&反馈详情)
查看>>
Vue.js 学习总结(13)—— Vue3 version 计数介绍
查看>>
OA项目之我的会议(会议排座&送审)
查看>>
OA项目之我的会议(查询)
查看>>
OA项目之我的审批(会议查询&会议签字)
查看>>
OA项目之项目简介&会议发布
查看>>
ObjC的复制操作
查看>>
Object c将一个double值转换为时间格式
查看>>
object detection之Win10配置
查看>>
object detection训练自己数据
查看>>
object detection错误Message type "object_detection.protos.SsdFeatureExtractor" has no field named "bat
查看>>
object detection错误之Could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
查看>>
object detection错误之no module named nets
查看>>
Object of type 'ndarray' is not JSON serializable
查看>>
Object Oriented Programming in JavaScript
查看>>
object references an unsaved transient instance - save the transient instance before flushing
查看>>
Object 类的常见方法有哪些?
查看>>
Object-c动态特性
查看>>