Flutter开发环境配置

server/2025/2/2 7:39:43/

下载 Flutter SDK

下载地址:https://docs.flutter.cn/get-started/install
M1/M2芯片选择带arm64字样的Flutter SDK。

解压

cd /Applications
unzip ~/Downloads/flutter_macos_arm64_3.27.3-stable.zip

执行

/Applications/flutter/bin/flutterManage your Flutter app development.Common commands:flutter create <output directory>Create a new Flutter project in the specified directory.flutter run [options]Run your Flutter application on an attached device or in an emulator.Usage: flutter <command> [arguments]Global options:
-h, --help                  Print this usage information.
-v, --verbose               Noisy logging, including all shell commandsexecuted.If used with "--help", shows hidden options. If usedwith "flutter doctor", shows additional diagnosticinformation. (Use "-vv" to force verbose logging inthose cases.)
-d, --device-id             Target device id or name (prefixes allowed).--version               Reports the version of this tool.--enable-analytics      Enable telemetry reporting each time a flutter ordart command runs.--disable-analytics     Disable telemetry reporting each time a flutter ordart command runs, until it is re-enabled.--suppress-analytics    Suppress analytics reporting for the current CLIinvocation.Available commands:Flutter SDKbash-completion   Output command line shell completion setup scripts.channel           List or switch Flutter channels.config            Configure Flutter settings.doctor            Show information about the installed tooling.downgrade         Downgrade Flutter to the last active version for the currentchannel.precache          Populate the Flutter tool's cache of binary artifacts.upgrade           Upgrade your copy of Flutter.Projectanalyze           Analyze the project's Dart code.assemble          Assemble and build Flutter resources.build             Build an executable app or install bundle.clean             Delete the build/ and .dart_tool/ directories.create            Create a new Flutter project.drive             Run integration tests for the project on an attached deviceor emulator.gen-l10n          Generate localizations for the current project.pub               Commands for managing Flutter packages.run               Run your Flutter app on an attached device.test              Run Flutter unit tests for the current project.Tools & Devicesattach            Attach to a running app.custom-devices    List, reset, add and delete custom devices.devices           List all connected devices.emulators         List, launch and create emulators.install           Install a Flutter app on an attached device.logs              Show log output for running Flutter apps.screenshot        Take a screenshot from a connected device.symbolize         Symbolize a stack trace from an AOT-compiled Flutter app.Run "flutter help <command>" for more information about a command.
Run "flutter help -v" for verbose help output, including less commonly used
options.

设置代理

export http_proxy="127.0.0.1:1087"
export https_proxy="127.0.0.1:1087"
export NO_PROXY=localhost,127.0.0.1,::1

VSCode配置PATH

Windows下按快捷键Shift+Ctrl+P或MacOS下按快捷键Shift+Command+P打开命令面板,搜索install code,执行install 'code' command in PATH

Windows配置文件:cmder/config/user_profile.sh
macOS配置文件路径:~/.zprofile

code ~/.zprofile
export PATH="$PATH:/Applications/flutter/bin"

重启终端,PATH就会生效。

配置国内镜像

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE=https://storage.flutter-io.cn# export PUB_HOSTED_URL=https://mirrors.sjtug.edu.cn
# export FLUTTER_STORAGE_BASE=https://dart-pub.mirrors.sjtug.sjtug.edu.cn

安装Rosetta

Rosetta用来把Mac下的M1/M2芯片翻译成兼容的指令。

sudo softwareupdate --install-rosetta --agree-to-license

安装Xcode

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch

配置gem镜像

# 查看镜像
gem sources# 移除原始镜像
gem sources --remove https://rubygems.org/# 添加阿里云镜像
gem sources -a https://mirrors.aliyun.com/rubygems/

安装cocoapods

cocoapods是Swift语言的包管理工具。

# 安装
brew install cocoapods# 链接
brew link --overwrite cocoapods# 查看版本
pod --version# 升级
sudo gem install cocoapods -v 1.13.0

安装Android开发环境

下载安装Android Studio:https://developer.android.google.cn/studio?hl=zh-cn

flutter doctor --android-licenses

flutter_167">查看flutter健康状况

flutter doctor                       
Doctor summary (to see all details, run flutter doctor -v):
[] Flutter (Channel stable, 3.27.3, on macOS 15.3 24D60 darwin-arm64, localezh-Hans-CN)
[] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[] Xcode - develop for iOS and macOS (Xcode 16.2)
[] Chrome - develop for the web
[] Android Studio (version 2024.2)
[] IntelliJ IDEA Ultimate Edition (version 2022.2)
[] VS Code (version 1.96.4)
[] VS Code (version 1.96.4)
[] Proxy Configuration
[] Connected device (4 available)
[] Network resources• No issues found!

创建Flutter项目

cd ~/desktop
flutter create hello_world
cd ~/desktop/hello_world
code ./

1


http://www.ppmy.cn/server/164273.html

相关文章

Springboot使用AOP时,需不需要引入AspectJ?

Springboot使用AOP时,需不需要引入AspectJ? 在Spring Boot中使用AOP时&#xff0c;是否需要引入AspectJ取决于你选择的具体AOP实现方式。以下是详细分步说明&#xff1a; 1. 默认场景&#xff1a;使用Spring AOP&#xff08;基于代理&#xff09; 不需要引入AspectJ依赖&am…

VScode+Latex (Recipe terminated with fatal error: spawn xelatex ENOENT)

使用VSCode编辑出现Recipe terminated with fatal error: spawn xelatex ENOENT问题咋办&#xff1f; 很好解决&#xff0c;大概率的原因是因为latex没有添加到系统环境变量中&#xff0c;所有设置的编译工具没有办法找到才出现的这种情况。 解决方法&#xff1a; winR 然后输…

大厂面试题备份20250130

20250130 RAG怎么做的&#xff0c;召回效果 RAG&#xff08;Retrieval-Augmented Generation&#xff0c;检索增强生成&#xff09; 是一种将信息检索与生成式模型&#xff08;如 GPT&#xff09;相结合的技术&#xff0c;旨在提升生成模型的答案质量&#xff0c;特别是在需要…

Linux《基础指令》

在之前的Linux《Linux简介与环境的搭建》当中我们已经初步了解了Linux的由来和如何搭建Linux环境&#xff0c;那么接下来在本篇当中我们就要来学习Linux的基础指令。在此我们的学习是包括两个部分&#xff0c;即指令和关于Linux的基础知识&#xff1b;因此本篇指令和基础知识的…

C++ 中的引用(Reference)

在 C 中&#xff0c;引用&#xff08;Reference&#xff09;是一种特殊的变量类型&#xff0c;它提供了一个已存在变量的别名。引用在很多场景下都非常有用&#xff0c;比如函数参数传递、返回值等。下面将详细介绍 C 引用的相关知识。 1. 引用的基本概念和语法 引用是已存在…

IDEA构建JavaWeb项目,并通过Tomcat成功运行

目录 一、Tomcat简介 二、Tomcat安装步骤 1.选择分支下载 2.点击下载zip安装包 3.解压到没有中文、空格和特殊字符的目录下 4.双击bin目录下的startup.bat脚本启动Tomcat 5.浏览器访问Tomcat 6.关闭Tomcat服务器 三、Tomcat目录介绍 四、WEB项目的标准结构 五、WEB…

MSA Transformer

过去的蛋白质语言模型以单个序列为输入&#xff0c;MSA Transformer以多序列比对的形式将一组序列作为输入。该模型将行和列注意力交织在输入序列中&#xff0c;并在许多蛋白质家族中使用mask语言建模目标进行训练。模型的性能远超过了当时最先进的无监督学习方法&#xff0c;其…

【自学嵌入式(8)天气时钟:天气模块开发、主函数编写】

天气时钟&#xff1a;天气模块开发、主函数编写 I2C协议和SPI协议I2C&#xff08;Inter-Integrated Circuit&#xff09;SPI&#xff08;Serial Peripheral Interface&#xff09; 天气模块心知天气预报使用HTTPClient类介绍主要功能常用函数注意事项 JSON介绍deserializeJson函…