Flutter 中文网入门、进阶、实例篇

这是dart的语法

Google 的 Mobile UI 框架 Flutter Preview 1 发布 发布于2018年06月21日

// D:\flutter\bin>flutter upgrade
Your flutter checkout has local changes that would be erased by upgrading. If you want to keep these changes, it is recommended that you stash
them via “git stash” or else commit the changes to a local branch. If it is okay to remove local changes, then re-run this command with –force.

参考:学习 Flutter 遇到的一些问题

执行更新命令之前,先双击 flutter.bat,更新完之后记得修改 flutter.gradle

D:\flutter\bin>flutter upgrade --force # 这里会阻塞十分钟左右需要耐心等待
Upgrading Flutter from D:\flutter...

// Creating flutter Project… 创建项目

在中国网络环境下使用 Flutter

Flutter配置镜像

// unable to locate adb

参考:【解决方法】unable to locate adb

环境:Android Studio 4.0
打开虚拟设备时,弹出“unable to locate adb”
解决方法:往往报错是因为SDK没有被选中。
File-Project Structure-Project SDK
正确填写SDK路径。

// Flutter App Run卡在Running Gradle task ‘assembleDebug’…

参考:Flutter App Run卡在Running Gradle task ‘assembleDebug’…

参考:解决Flutter项目卡在Initializing gradle…界面的问题

关键代码放在最前面:

// 要修改内容的文件:gradle-wrapper.properties
        distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
// 要修改内容的文件:flutter.gradle; build.gradle; // buildscript { repositories { // 添加这里 } }
        maven { url 'https://maven.aliyun.com/repository/central' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }

        mavenLocal()

        google()
        jcenter()

1.修改 gradle 为自己电脑中下载好的 gradle 版本(共3步)

distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

2.修改 flutter sdk 中的 flutter.gradle(共3步)

maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/public' }

mavenLocal()

google()
jcenter()

3. 修改项目中的 gradle(共3步)

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        maven { url 'https://maven.aliyun.com/repository/central' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }

        mavenLocal()

        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/central' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }

        mavenLocal()

        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

 

 

作者 wanglei

发表评论