Flutter开发环境配置

news/2025/2/2 18:06:12/

下载 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/news/1568756.html

相关文章

怎么调整香港服务器硬盘分区大小?

调整香港服务器的硬盘分区大小需要小心操作&#xff0c;因为操作不当可能会导致数据丢失。以下是如何在 Linux 和 Windows 系统中调整硬盘分区大小的详细步骤&#xff1a; Linux 系统调整硬盘分区大小&#xff1a; 1. 检查当前分区情况 运行以下命令查看硬盘分区信息&#xff1…

vim多文件操作如何同屏开多个文件

[rootxxx ~]# vimdiff aa.txt bb.txt cc.txt #带颜色比较的纵向排列打开的同屏多文件操作 示例&#xff1a; [rootxxx ~]# vimdiff -o aa.txt bb.txt cc.txt #带颜色比较的横向排列打开的同屏多文件操作 示例&#xff1a; [rootxxx ~]# vim -O aa.txt bb.txt c…

Synology 群辉NAS安装(10)安装confluence

Synology 群辉NAS安装&#xff08;10&#xff09;安装confluence 写在前面本着一朝鲜吃遍天的原则&#xff0c;我又去了这个github的作者那里翻车的第一次尝试手工创建数据库制作一个新的docker-compose of confluence 不折腾但成功启动的版本 写在前面 在装完jira之后&#x…

react-native网络调试工具Reactotron保姆级教程

在React Native开发过程中&#xff0c;调试和性能优化是至关重要的环节。今天&#xff0c;就来给大家分享一个非常强大的工具——Reactotron&#xff0c;它就像是一个贴心的助手&#xff0c;能帮助我们更轻松地追踪问题、优化性能。下面就是一份保姆级教程哦&#xff01; 一、…

Golang 执行流程分析

文章目录 1. 编译和运行2. 编译和运行说明 1. 编译和运行 如果是对源码编译后&#xff0c;再执行&#xff0c;Go的执行流程如下图 如果我们是对源码直接 执行 go run 源码&#xff0c;Go的执行流程如下图 两种执行流程的方式区别 如果先编译生成了可执行文件&#xff0c;那么…

网络仿真工具Core环境搭建

目录 安装依赖包 源码下载 Core安装 FAQ 下载源码TLS出错误 问题 解决方案 找不到dbus-launch 问题 解决方案 安装依赖包 调用以下命令安装依赖包 apt-get install -y ca-certificates git sudo wget tzdata libpcap-dev libpcre3-dev \ libprotobuf-dev libxml2-de…

Linux:线程池和单例模式

一、普通线程池 1.1 线程池概念 线程池&#xff1a;一种线程使用模式。线程过多会带来调度开销&#xff0c;进而影响缓存局部性和整体性能。而线程池维护着多个线程&#xff0c;等待着监督管理者分配可并发执行的任务。这避免了在处理短时间任务时创建与销毁线程的代价&…

[论文总结] 深度学习在农业领域应用论文笔记14

当下&#xff0c;深度学习在农业领域的研究热度持续攀升&#xff0c;相关论文发表量呈现出迅猛增长的态势。但繁荣背后&#xff0c;质量却不尽人意。相当一部分论文内容空洞无物&#xff0c;缺乏能够落地转化的实际价值&#xff0c;“凑数” 的痕迹十分明显。在农业信息化领域的…