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

Flutter开发环境配置

下载 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健康状况

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.lryc.cn/news/529931.html

相关文章:

  • Two Divisors ( Educational Codeforces Round 89 (Rated for Div. 2) )
  • 亚博microros小车-原生ubuntu支持系列:17 gmapping
  • Java面试题2025-并发编程进阶(线程池和并发容器类)
  • Stable Diffusion 3.5 介绍
  • 云计算部署模式全面解析
  • Vue 与 Electron 结合开发桌面应用
  • 数据库优化:提升性能的关键策略
  • 使用openAI与Deepseek的感受
  • pytorch实现长短期记忆网络 (LSTM)
  • 【ubuntu】双系统ubuntu下一键切换到Windows
  • 【PyTorch】6.张量形状操作:在深度学习的 “魔方” 里,玩转张量形状
  • 大模型GUI系列论文阅读 DAY4续:《Large Language Model Agent for Fake News Detection》
  • 论文阅读(九):通过概率图模型建立连锁不平衡模型和进行关联研究:最新进展访问之旅
  • python小知识-typing注解你的程序
  • git基础使用--1--版本控制的基本概念
  • “新月智能武器系统”CIWS,开启智能武器的新纪元
  • JVM运行时数据区域-附面试题
  • 增删改查(CRUD)操作
  • Vue.js `Suspense` 和异步组件加载
  • HTB:LinkVortex[WriteUP]
  • Linux命令入门
  • 【问题】Chrome安装不受支持的扩展 解决方案
  • 【题解】AtCoder Beginner Contest ABC391 D Gravity
  • 使用 SpringBoot+Thymeleaf 模板引擎进行 Web 开发
  • 【Java异步编程】CompletableFuture综合实战:泡茶喝水与复杂的异步调用
  • Nginx知识
  • Unity开发游戏使用XLua的基础
  • AI-ISP论文Learning to See in the Dark解读
  • OpenCV:开运算
  • 38. RTC实验