Flutter 一:环境配置

1、 环境搭建步骤参考

Flutter:https://flutter.cn/docs/get-started/install/windows

2、错误

在这里插入图片描述
解决方式:
1 找到 flutter目录下 \flutter\packages\flutter_tools\lib\src\http_host_validator.dart
2 修改 const String kCloudHost = ‘https://storage.googleapis.com/’; 为 const String kCloudHost = ‘https://storage.flutter-io.cn’;

在这里插入图片描述
解决方式:
const String kMaven = ‘"https://maven.google.com’;
改为
const String kMaven = ‘http://maven.aliyun.com/nexus/content/groups/public/’;

Flutter 一:环境配置_第1张图片
解决方式
将镜像地址配置到系统环境变量中去
PUB_HOSTED_URL=https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

build.gradle 配置

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        maven { url 'https://storage.googleapis.com/download.flutter.io' }
        maven { url 'https://download.flutter.io' }
        maven { url "https://maven.aliyun.com/repository/public" }
        maven { url "https://maven.aliyun.com/repository/central" }
        maven { url "https://maven.aliyun.com/repository/jcenter" }
        maven { url "https://maven.aliyun.com/repository/google" }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
//        mavenLocal()
//        mavenCentral()
    }

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

allprojects {
    repositories {
        maven { url 'https://storage.googleapis.com/download.flutter.io' }
        maven { url 'https://download.flutter.io' }
        maven { url "https://maven.aliyun.com/repository/public" }
        maven { url "https://maven.aliyun.com/repository/central" }
        maven { url "https://maven.aliyun.com/repository/jcenter" }
        maven { url "https://maven.aliyun.com/repository/google" }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
//        mavenLocal()
//        mavenCentral()
    }
}

总结

1 E:\flutter\packages\flutter_tools\lib\src\http_host_validator.dart

修改为如下:

const String kCloudHost = 'https://storage.flutter-io.cn';
const String kCocoaPods = 'https://cocoapods.org/';
const String kGitHub = 'https://github.com/';
const String kMaven = 'http://maven.aliyun.com/nexus/content/groups/public/';
const String kPubDev = 'https://pub.dev/';
2 E:\flutter\packages\flutter_tools\gradle\resolve_dependencies.gradle

添加如下
Flutter 一:环境配置_第2张图片

3 E:\flutter\packages\flutter_tools\gradle\src\main\groovy

添加如下
Flutter 一:环境配置_第3张图片

Dart下载

从GitHub下载DART库zip包,注意下载带版本号(tags)的压缩包,不要从master下载。
下载链接prefer:https://github.com/dartsim/dart

你可能感兴趣的:(flutter)