flutter 国内源

Flutter 在中国由于网络原因,从官方默认的国外源下载Dart包和Flutter SDK可能会比较慢或者不稳定。为了加速依赖包的获取与Flutter SDK的安装,可以使用国内镜像源。以下是一些国内常用的Flutter和Dart包镜像源:

清华大学开源软件镜像站

Flutter SDK: https://mirrors.tuna.tsinghua.edu.cn/flutter/

Pub(Dart package manager): https://mirrors.tuna.tsinghua.edu.cn/dart-pub/

阿里云镜像

Flutter SDK: https://mirrors.aliyun.com/flutter/

Pub: https://mirrors.aliyun.com/pub/

USTC(中国科学技术大学)开源软件镜像

Flutter SDK: https://mirrors.ustc.edu.cn/flutter/

Pub: https://mirrors.ustc.edu.cn/dart-pub/

北京大学开源镜像站

可能也提供Flutter和Dart的镜像服务,请查看其官网以确认最新链接。

在配置Flutter环境时,若要更换为国内源,通常需要修改flutter目录下的flutter.yaml配置文件(对于旧版本可能需编辑.pub-cache目录下的配置文件),或者设置环境变量PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL来指向上述国内镜像站点。

例如,在命令行中设置环境变量:

Bash

export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub/

export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter/

然后进行Flutter的常规操作,如更新、安装或拉取依赖等。如果长期使用,可以把这两个环境变量添加到你的shell配置文件(如:.bashrc、.bash_profile 或 .zshrc)中以便持久化生效。记得根据实际情况选择合适的镜像站地址。

相关推荐
早起的年轻人6 小时前
Flutter String 按 ,。分割
flutter
helloxmg16 小时前
鸿蒙harmonyos next flutter通信之MethodChannel获取设备信息
flutter
helloxmg16 小时前
鸿蒙harmonyos next flutter混合开发之开发package
flutter·华为·harmonyos
lqj_本人2 天前
flutter_鸿蒙next_Dart基础②List
flutter
lqj_本人2 天前
flutter_鸿蒙next_Dart基础①字符串
flutter
The_tuber_sadness2 天前
【Flutter】- 基础语法
flutter
helloxmg2 天前
鸿蒙harmonyos next flutter通信之BasicMessageChannel获取app版本号
flutter
linpengteng2 天前
使用 Flutter 开发数字钱包应用(Dompet App)
前端·flutter·firebase