当前位置: 首页 > article >正文

windows安装flutter

在flutter官网下载flutter

在 Windows 操作系统上安装和配置 Flutter 开发环境 - Flutter 中文文档 - Flutter 中文开发者网站 - Flutter

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cmtVGl24-1682665466509)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426154435066.png)]

下载文件后,解压文件把文件存放在指定位置

打开flutter_console.bat文件

输入flutter doctor

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-iASKviaX-1682665466511)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426154349254.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)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-9WbrkbI7-1682665466513)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426155315218.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)]

打开Android Studio 右上角 打开设置

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OfbJ13Ie-1682665466515)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426160112695.png)]

打开Android SDK 右上角显示Android SDK Location 会显示存放的SDK路径

如果没有显示 点击Android SDK Location 后的提示,根据提示操作

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jGnm9pnr-1682665466515)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426160154424.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)]

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)]

选择完成后自动下载

安装完成后再次执行flutter doctor --android-licenses

无报错后执行flutter doctor

image-20230426160535390

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)]

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)]

再次运行flutter doctor

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TzdZPCUr-1682665466522)(C:\Users\zhangmj2\Desktop\VMware Workstation\图片\image-20230426162938600.png)]


http://www.kler.cn/a/15997.html

相关文章:

  • Day44 | 动态规划 :状态机DP 买卖股票的最佳时机IV买卖股票的最佳时机III
  • Spring boot + Vue2小项目基本模板
  • 机器学习 ---线性回归
  • Tiktok对接和内容发布申请流程
  • Android CCodec Codec2 (二一)InputBuffers
  • Python小游戏24——小恐龙躲避游戏
  • 【JavaEE进阶】——第四节.Spring更简单的实现Bean对象的存取(利用注解储存和注入Bean对象)
  • Spring Cloud Kubernetes使用全解(一)—官方原版
  • 【Java笔试强训 12】
  • 如何选择多参数水质分析仪?
  • windbg查看64位dump文件踩过的坑:没有二进制文件导致堆栈异常
  • BM48-数据流中的中位数
  • ChatGPT Plus价格太贵,可以约上三五知己一起上车体验一下,这个项目就能帮到你
  • 【ChatGPT】阿里版 ChatGPT 突然官宣意味着什么?
  • 力扣,合并石头最低成本算法题
  • Java Memory Model
  • 【7. ROS 中的 IMU 惯性测量单元消息包】
  • 有效日志管理在软件开发和运营中的作用
  • 某医院网络安全分析案例
  • 源码安装工具checkinstall使用
  • stable diffusion的使用
  • Windows10本地搭建网站教程 - 内网穿透发布公网访问
  • c#笔记-代码格式
  • 【MySQL】外连接查询
  • 浅谈一下布隆过滤器的设计之美
  • 【Python】实战:Python 实现前端、后端管理系统部署