1
【笔记】Flutter学习笔记
source link: https://loli.fj.cn/2023/06/09/Flutter%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
【笔记】Flutter学习笔记
2023-06-09Flutter学习指北
Flutter学习笔记
下载Flutter
brew install flutter
配置国内源(可选)
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
下载AndroidStudio
在AndroidStudio中的
Android SDK Manager
中安装Android SDK Command-line Tools
flutter doctor --android-licenses
下载真机调试环境(可选)
- 如果有一台Android手机作为真机调试工具,需要在
Android SDK Manager
中下载对应Android版本的SDK Platforms
下载Cocoapods
通过brew安装Cocoapods
brew install cocoapods
pod setup
直接通过Ruby安装Cocoapods
sudo gem install cocoapods
activesupport requires Ruby version >= 2.7.0. The current ruby version is 2.6.10.210.
- gem版本过低,需要升级版本
sudo gem install activesupport -v 6.1.7.3
下载时查看日志
- 如果下载缓慢可以在下载时查看日志
sudo gem install cocoapods -V
换源(可选)
- 如果下载缓慢可以替换国内源
查看当前源
gem sources -l
替换国内源
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
还原默认源
gem sources --add https://rubygems.org/ --remove https://gems.ruby-china.com/
下载XCode
- 切换命令行工具为XCode而不是
XCode Command-line Tool
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
- 首次启动XCode
sudo xcodebuild -runFirstLaunch
Flutter环境检测
flutter doctor
查看详细信息
flutter doctor -v
查看所有设备
flutter devices
<project_name>
:项目名称
--org com
:添加包名
com
:包名,域名反写,不需要再添加一次项目名--description <text>
:添加项目描述
flutter create <project_name>
flutter run
运行在所有设备上
<device>
:启动调试的设备ID或设备名
all
:所有设备同时启动调试
flutter run -d <device>
- 在启动后的终端通过快捷键可以实现指定命令
r:热加载
R:热重启
p:显示/隐藏定位网格
o:切换Android/ios预览模式
q:退出调试
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK