flutter初体验demo踩坑指南

New Flutter Project 创建项目不成功

报错提示:Flutter create command was unsuccessful,然后打开项目文件里面就一个 .idea 文件夹,项目压根没创建成功。这个问题就是 flutter 没弄好,跟着下面一个问题就能解决了。

执行 flutter 命令,cmd终端直接闪退

按步骤下载了 flutter 的最新SDK文件(3.0.1版本,2022/5/20发布),也添加好了系统环境变量 path,在终端运行 where flutter dart 没问题,但是一运行 flutter doctor 命令时直接闪退了

解决办法

去放 flutter SDK文件的目录下运行 flutter doctor(直接在那个目录顶部的路径输入框输 cmd,小黑窗执行路径就会直接是当前目录)。等都设置好了,直接在默认的 C:UsersAdministrator> 里运行 flutter doctor 就不闪退了。

Visual Studio not installed

成功运行 flutter doctor 后又发现报错提示:

DANGER

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

晃眼一看以为是去 vscode 搜索安装 flutter 插件,心想这玩意咱熟悉呀,安装了重启 vscode,眼睛一闭一睁,flutter doctor 依然报错,才发现人让安装的是 Visual Studio(* 适用于 Windows 上 .NET 和 C++ 开发人员的最佳综合 IDE。 完整打包了一系列丰富的工具和功能,可提升和增强软件开发的每个阶段),并不是我们每天都在用的那个蓝色图标的 Visual Studio Code。

下载安装 Visual Studioopen in new window,选中“使用C++的桌面开发”和“使用C++的移动开发”,这东西安装有点费内存:

这个报错其实不管不安装 Visual Studio 也没问题的,直接安装好 Android Studioopen in new window 打开,安装 flutter 和 dart 插件,设置好安卓模拟器设备,然后 New Flutter Project 等待一会,再运行 main.dart 就能跑起来那个计数器 demo 应用了:

HTTP host "https://maven.google.com/" is not reachable. Reason: An error occurred while checking the HTTP host:信号灯超时时间已到

这个需要修改 https://maven.google.com/ 到国内的镜像源,如果不改 demo 也能跑起来。

解决步骤

展开阅读全文

页面更新:2024-06-01

标签:终端   文件夹   路径   插件   步骤   命令   提示   文件   目录   指南   项目

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top