Flutter开发环境配置

ops/2025/2/4 12:14:03/

下载 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/ops/155563.html

相关文章

基于Spring Security 6的OAuth2 系列之八 - 授权服务器--Spring Authrization Server的基本原理

之所以想写这一系列&#xff0c;是因为之前工作过程中使用Spring Security OAuth2搭建了网关和授权服务器&#xff0c;但当时基于spring-boot 2.3.x&#xff0c;其默认的Spring Security是5.3.x。之后新项目升级到了spring-boot 3.3.0&#xff0c;结果一看Spring Security也升级…

1. 【.NET Aspire 从入门到实战】--理论入门与环境搭建--引言

在当前软件开发领域&#xff0c;云原生和微服务架构已经成为主流趋势&#xff0c;传统的单体应用正逐步向分布式系统转型。随着业务需求的不断变化与用户规模的迅速扩大&#xff0c;如何在保证高可用、高扩展性的同时&#xff0c;还能提高开发效率与降低维护成本&#xff0c;成…

LVS工作模式 DR 配置要点

LVS工作模式 DR direct routing 在DR模式中&#xff0c;所有的RS需要配置两个地址:RIP和VIP在DR模式中&#xff0c;LVS会通过arp获取到所有RS的IP地址和对应的MAC地址&#xff0c;因此LVS和RS需处于同一二层网络中当User发送请求到LVS后&#xff0c;LVS保持源目IP地址和端口号…

在 Ubuntu 上安装 Node.js 23.x

在 Ubuntu 上安装 Node.js 23.x 前提条件安装步骤1. 下载设置脚本2. 运行设置脚本3. 安装 Node.js4. 验证安装 参考链接总结 在现代 web 开发中&#xff0c;Node.js 是一个不可或缺的工具。它提供了一个强大的 JavaScript 运行时环境&#xff0c;使得开发人员可以在服务器端使用…

web前端13--动画

1、动画 语法&#xff1a;两种写法 csskeyframes big{0%{width: 200px;background-color: aqua;}50%{width: 500px;background-color: rgb(111, 255, 0);}100%{width: 300px;background-color: red;}}keyframes big{from{width: 200px;background-color: aqua;}to{width: 500…

利用matlab寻找矩阵中最大值及其位置

目录 一、问题描述1.1 max函数用法1.2 MATLAB中 : : :的作用1.3 ind2sub函数用法 二、实现方法2.1 方法一&#xff1a;max和find2.2 方法二&#xff1a;max和ind2sub2.3 方法对比 三、参考文献 一、问题描述 matlab中求最大值可使用函数max&#xff0c;对于一维向量&#xff0…

C++游戏开发实战:从引擎架构到物理碰撞

&#x1f4dd;个人主页&#x1f339;&#xff1a;一ge科研小菜鸡-CSDN博客 &#x1f339;&#x1f339;期待您的关注 &#x1f339;&#x1f339; 1. 引言 C 是游戏开发中最受欢迎的编程语言之一&#xff0c;因其高性能、低延迟和强大的底层控制能力&#xff0c;被广泛用于游戏…

【线程】基于环形队列的生产者消费者模型

1 环形队列 环形队列采用数组来模拟&#xff0c;用取模运算来模拟环状特性。 1.如何判断环形队列为空或者为满? 当环形队列为空时&#xff0c;头和尾都指向同一个位置。当环形队列为满时&#xff0c;头和尾也都指向同一个位置。 因此&#xff0c; 可以通过加计数器或者标记…