git安装flutter

  1. 首先设置 Flutter 的镜像环境变量(在 PowerShell 中运行):
powershell 复制代码
# 设置 Flutter 镜像
$env:PUB_HOSTED_URL="https://pub.flutter-io.cn"
$env:FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"

# 将这些环境变量永久保存
[System.Environment]::SetEnvironmentVariable('PUB_HOSTED_URL', 'https://pub.flutter-io.cn', 'User')
[System.Environment]::SetEnvironmentVariable('FLUTTER_STORAGE_BASE_URL', 'https://storage.flutter-io.cn', 'User')

转自

  1. 使用 Git 克隆 Flutter SDK(选择一个目录,比如 D:\development):
powershell 复制代码
# 创建目录
mkdir D:\development
cd D:\development

# 克隆 Flutter 仓库
git clone https://github.com/flutter/flutter.git -b stable
  1. 添加 Flutter 到环境变量
powershell 复制代码
# 添加 Flutter bin 目录到用户环境变量
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
$flutterPath = "D:\development\flutter\bin"
[Environment]::SetEnvironmentVariable('Path', "$userPath;$flutterPath", 'User')
  1. 重新打开新的 PowerShell 窗口,运行 Flutter doctor 检查环境
powershell 复制代码
flutter doctor

如果 GitHub 访问较慢,可以使用 Gitee 镜像:

powershell 复制代码
git clone https://gitee.com/mirrors/Flutter.git -b stable flutter

注意事项:

  1. 确保已经安装了 Git
  2. 安装路径不要包含中文和特殊字符
  3. 如果 flutter doctor 提示需要安装其他组件:
    • Android Studio
    • Visual Studio(安装 Desktop development with C++)
    • VS Code

常见问题解决:

  1. 如果下载速度慢,可以使用 Git 代理:
powershell 复制代码
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890
  1. 如果需要取消代理:
powershell 复制代码
git config --global --unset http.proxy
git config --global --unset https.proxy

完成安装后,可以验证安装:

powershell 复制代码
flutter --version
flutter doctor
相关推荐
Mandy的名字被占用了7 小时前
Dart 与 Flutter 快速入门指南
后端·flutter·dart
一只楚楚猫9 小时前
一篇文章入门Git工具
git
Irissgwe10 小时前
第 6 篇:Git 分支进阶:分支策略、stash、bugfix 和 feature 开发
git
wok15710 小时前
Git Bash 执行中文命令报错 127:MSYS 参数编码 bug 排查与修复
git·bug·bash
心中有国也有家10 小时前
Flutter 鸿蒙编译与构建流程深度解析
学习·flutter·华为·harmonyos
心中有国也有家1 天前
使用 DevEco Studio 配置 Flutter 鸿蒙签名
学习·flutter·华为·harmonyos
霸道流氓气质1 天前
CodeBuddy中使用 MCP 工具将 XMind 思维导图转换为 Markdown —— 实操流程汇总
git·myeclipse·xmind
nice先生的狂想曲1 天前
Stream与StreamController以及对应的使用场景
flutter·客户端
心中有国也有家1 天前
鸿蒙Flutter开发环境从零搭建教程(Windows/macOS双平台·避坑版)
学习·flutter·华为·harmonyos
心中有国也有家1 天前
Flutter 鸿蒙适配第一步:从 hive 迁移到 hive\_ce
hive·学习·flutter·华为·harmonyos