Flutter_Mac环境安装+运行

2022-07-20 14:15:03 浏览数 (1)

需要安装XcodeAndroid StudioFlutter

  • Xcode:AppStore 安装即可
  • Android Studio:

官网下载

  • Flutter

打开terminal

克隆Flutter项目:git clone -b beta https://github.com/flutter/flutter.git

导出到Flutter保存路径:export PATH=pwd/flutter/bin:$PATH

进入Flutter文件夹:cd ./flutter

检查Flutter环境:flutter doctor(这里有报错就按提示运行操作就行,没报错了,说明环境OK)

  • Create

创建项目:flutter create XXXX

进入项目文件夹:cd XXXX

运行:flutter run (会下载一堆tools)

  • Run

查看支持运行的虚拟机:flutter emulator

启动iOS虚拟机:flutter emulators --launch apple_ios_simulator

启动Android虚拟机:flutter emulators --launch Nexus_5X_API_28

查看支持运行的设备:flutter devices (可以看到deviceID)(虚拟机得启动起来才能看得到哦)

通过deviceId指定设备运行:

flutter run -d 47F96679-E23E-4FB0-9161-9DC7B4F076BA (iOS的)

flutter run -d emulator-5554 (Android的)

0 人点赞