win11+vscode+Flutter 开发环境配置

https://blog.csdn.net/Oven_maizi/article/details/126804404

1 vscode插件 安装

安装红框中的两个

2 flutter sdk 安装

dart sdk 包含在flutter sdk 里面,路径:flutter_windows_3.24.1-stable\flutter\bin\cache\dart-sdk

方式1:

通过vscode安装Flutter插件后,ctrl+shift+p 输入flutter,vscode的右下角会提示安装Flutter sdk

方式2:

版本列表 | Flutter 中文文档 - Flutter 中文开发者网站 - Flutter

方式3:

下载源码到一个目录,添加它的bin目录路径到 环境变量 中

git clone https://github.com/flutter/flutter.git

3 新建一个 flutter 项目

新建Flutter项目后,可以在lib目录通过终端去执行演示程序

4 演示程序执行前 flutter doctor 检查

首次运行 flutter doctor 报的错误,可以看到报错提示,安卓开发、win开发 还缺少依赖,但

web开发是可以的,那么只需要解决 网络资源不可用问题

PS E:\workspace\test_drive\flutter_application_1\lib> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.24.1, on Microsoft Windows [版本 10.0.22631.4037], locale zh-CN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/windows-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[!] Android Studio (not installed)
[√] Connected device (3 available)
[!] Network resources
    X A network error occurred while checking "https://maven.google.com/": 信号灯超时时间已到


! Doctor found issues in 4 categories.

临时解决办法:

在中国网络环境下使用 Flutter | Flutter 中文文档 - Flutter 中文开发者网站 - Flutter

根据上述文档,在powerShell执行下述命令

 $env:PUB_HOSTED_URL="https://pub.flutter-io.cn"
 $env:FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"

再次运行  flutter dockor,网络错误已经解决。

PS E:\workspace\test_drive\flutter_application_1\linux> flutter doctor
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.24.1, on Microsoft Windows [版本 10.0.22631.4037], locale zh-CN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/windows-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[!] Android Studio (not installed)
[√] Connected device (3 available)
[√] Network resources

! Doctor found issues in 3 categories.

最终解决办法:

后面又发现上述命令只是临时修改当前终端的环境变量,还需在 Windows 中永久设置环境变量

验证环境变量是否生效

新启动一个powershell,执行下述代码,回显不为空才对

echo $env:PUB_HOSTED_URL

4 web开发

下载一个谷歌

5 android开发 额外配置

1 下载 android studio 

https://developer.android.com/studio/install?hl=zh-cn#windows

2 android studio 安装包,引导式安装 一路都是默认,目标是安装好下面组件

3 打开android studio,额外安装命令行工具

4. 新建android 虚拟机

5.演示程序运行在安卓平台前检查

5.使用vscode启动安卓虚拟机

如果vscode打开安卓模拟器失败,可能的原因是gradle没有下载到模拟器里面,或者下载的时候,手动终止了导致gradle目录文件不完整,需要删除整个目录,C:\Users\Administrator\.gradle重新下载。

C:\Users\Administrator\.gradle\wrapper\dists\gradle-7.6.3-all

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值