在flutter官网下载flutter
在 Windows 操作系统上安装和配置 Flutter 开发环境 - Flutter 中文文档 - Flutter 中文开发者网站 - Flutter
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cmtVGl24-1682665466509)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426154435066.png)]](https://img-blog.csdnimg.cn/0c025ded7719407a907f58709bb23509.png)
下载文件后,解压文件把文件存放在指定位置
打开flutter_console.bat文件
输入flutter doctor
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-iASKviaX-1682665466511)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426154349254.png)]](https://img-blog.csdnimg.cn/f2a98296650a4d4e94fc6d3aaa76f974.png)

flutter报错提示(一)
执行flutter doctor 提示 Windows Version (Unable to confirm if installed Windows version is 10 or greater)
Windows Version (Unable to confirm if installed Windows version is 10 or greater)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zGmNK07G-1682665466513)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426154924762.png)]](https://img-blog.csdnimg.cn/4511b8fbaa754196b50b6ae360e3d490.png)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-9WbrkbI7-1682665466513)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426155315218.png)]](https://img-blog.csdnimg.cn/5f49b57aad2d4b769a01b7a19d252bb4.png)
把该目录下的文件替换为下面的代码
flutter\packages\flutter_tools\lib\src\windows\windows_version_validator.dart
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:process/process.dart';
import '../base/io.dart';
import '../doctor_validator.dart';
// FIX #1 - Remove everything from line 10 to 20 in original source code.
/// Validator for supported Windows host machine operating system version.
class WindowsVersionValidator extends DoctorValidator {
const WindowsVersionValidator({required ProcessManager processManager})
: _processManager = processManager,
super('Windows Version');
final ProcessManager _processManager;
@override
Future<ValidationResult> validate() async {
// FIX #2 - Replace 'systeminfo' by 'ver' command
final ProcessResult result =
await _processManager.run(<String>['ver'], runInShell: true);
if (result.exitCode != 0) {
return const ValidationResult(
ValidationType.missing,
<ValidationMessage>[],
statusInfo: 'Exit status from running `systeminfo` was unsuccessful',
);
}
final String resultStdout = result.stdout as String;
// FIX #3 - Remove brackets from output
final String resultAdjusted = resultStdout.replaceAll('[','').replaceAll(']','');
// FIX #4 - Split the output at spaces, and get Windows version at position 3.
// Split again at dots and get the major version at position 0.
// Cast the output to int.
final int winver = int.parse(resultAdjusted.split(' ').elementAt(3).split('.').elementAt(0));
// Use the string split method to extract the major version
// and check against the [kUnsupportedVersions] list
final ValidationType windowsVersionStatus;
final String statusInfo;
// FIX #5 - Check if Windows major version is greater than 10.
// Succeeds if true.
if (winver >= 10) {
windowsVersionStatus = ValidationType.installed;
statusInfo = 'Installed version of Windows is version 10 or higher';
} else {
windowsVersionStatus = ValidationType.missing;
statusInfo =
'Unable to confirm if installed Windows version is 10 or greater';
}
return ValidationResult(
windowsVersionStatus,
const <ValidationMessage>[],
statusInfo: statusInfo,
);
}
}
删除文件 flutter\bin\cache\flutter_tools.stamp/ (不删除也可以,先执行flutter doctor如果报错再删除文件)
flutter报错提示(二)
执行flutter doctor 提示[X] Android toolchain - develop for Android devices
[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/docs/get-started/install/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.
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2pZ6Vsum-1682665466514)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426155706735.png)]](https://img-blog.csdnimg.cn/689e0655f04f4073a65d5eae65727741.png)
打开Android Studio 右上角 打开设置
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OfbJ13Ie-1682665466515)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426160112695.png)]](https://img-blog.csdnimg.cn/b11bcbb661484c3c948c6145479c1da1.png)
打开Android SDK 右上角显示Android SDK Location 会显示存放的SDK路径
如果没有显示 点击Android SDK Location 后的提示,根据提示操作
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jGnm9pnr-1682665466515)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426160154424.png)]](https://img-blog.csdnimg.cn/c6f8b95a538f4b33beb82fefafb902cc.png)
执行
flutter config --android-sdk C:\Users\zhangmj2\AppData\Local\Android\Sdk
Setting "android-sdk" value to "C:\Users\zhangmj2\AppData\Local\Android\Sdk".
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ozzcIu5V-1682665466516)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426155939051.png)]](https://img-blog.csdnimg.cn/47a508134f0645b78ef6210ff8942764.png)
flutter报错提示(三)
执行flutter doctor 提示[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
需要执行flutter doctor --android-licenses
flutter doctor --android-licenses
Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.
执行flutter doctor --android-licenses后提示
Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.
打开Android Studio 右上角 打开设置 选择Android SDK
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ds1Zb7hQ-1682665466518)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426160911525.png)]](https://img-blog.csdnimg.cn/6c6d1c76a52f4f98ae0fc2f9b19579ef.png)
选择完成后自动下载
安装完成后再次执行flutter doctor --android-licenses
无报错后执行flutter doctor
flutter报错提示(四)
执行flutter doctor 提示需要安装Visual Studio 如果不需要开发,可以不用安装
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eBzdm7tt-1682665466520)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426161100636.png)]](https://img-blog.csdnimg.cn/f6160d3021cd4242a41314d64cc982c3.png)
flutter提示报错(五)
执行flutter doctor 提示 X HTTP host “https://maven.google.com/” is not reachable. Reason: An error occurred while checking the HTTP host: 信号灯超时时间已到
HTTP Host availability check is taking a long time...[!] HTTP Host Availability
X HTTP host "https://maven.google.com/" is not reachable. Reason: An error occurred while checking the HTTP host: 信号灯超时时间已到
X HTTP host "https://cloud.google.com/" is not reachable. Reason: An error occurred while checking the HTTP host: 信号灯超时时间已到
在flutter安装路径下找到flutter/packages/flutter_tools/lib/src/http_host_validator.dart文件
将https://maven.google.com/ 修改为https://dl.google.com/dl/android/maven2/
并打开flutter\bin\cache 删除flutter_tools.snapshot文件,永久删除。
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2P94bWKG-1682665466521)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426162751704.png)]](https://img-blog.csdnimg.cn/00723162089e4c9a8140ca3787b7302c.png)
再次运行flutter doctor
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TzdZPCUr-1682665466522)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426162938600.png)]](https://img-blog.csdnimg.cn/5b2ed19ac6814565bda3ddf5bea3780f.png)


















