Flutter 一:环境配置

发布时间:2023年12月18日

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/’;

在这里插入图片描述
解决方式
将镜像地址配置到系统环境变量中去
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

添加如下
在这里插入图片描述

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

添加如下
在这里插入图片描述

Dart下载

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

文章来源:https://blog.csdn.net/weixin_41648633/article/details/135059473
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。