明天開始又要上班了,你的假期任務完成如何啊?因爲平時加班太多了,實在擠不出更多時間,從開始想用 Flutter 《Flutter 開發從 0 到 1(一)需求與準備》寫一個完整的 APP 已通過去三個月了,可是我沒有忘記,這個國慶時間我終於完成了。Flutter 確實強大,不止跨平臺,還支持桌面應用,包括 Window、macOS、Linux,以及 Web 應用,真正一套代碼,全平臺支持,野心可見一斑。android
以上我嘗試過了,打包成了 APK、macOS 桌面應用、Web 應用沒問題,只能用兩個字形容 Flutter:牛皮,今天先分享這個 APP 源碼。web
大致功能以下:windows
頁面 | 知識點 | 效果預覽 |
---|---|---|
框架 | 一、右滑菜單;二、個人收藏 | |
博客列表 | 一、佈局;二、ListView 下拉刷新好和加載更多 | |
博客詳情 | 一、Markdown 渲染;二、代碼高亮、三、收縮 FloatingActionButton、四、收藏 | |
評論列表 | 一、佈局;二、評論 | |
帳戶 | 一、登陸、二、註冊 |
拿到源碼,能夠以 Web Server (web) 或 Chrome (web)運行代碼, 若是你是 MacBook Pro,你還能夠以 iPhone 11 Pro Max (mobile)或 macOS (desktop)運行,運行到 Android 手機,開發的時候卡在了 Running Gradle task ‘assembleDebug’…或者‘assembleRelease’,這裏記錄下,這時候通常在下載 Gradle 並配置項目,因此可能出現的問題通常有兩種:api
報錯一:markdown
> 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
下。app
若是 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
目錄下便可。maven
報錯二:oop
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" }
}
}
複製代碼
公號「吳小龍同窗」回覆關鍵字「AndBlog」獲取源碼下載連接。
後續更新,這個連接均可以訪問,來,咱們一塊兒繼續探討 Flutter。