AndroidStudio 插件安裝位置
/Applications/Android Studio.app/Contents/plugins
清除Flutter 緩存文件
清除該目錄下文件
flutter/bin/cache/lockfile
斷點(diǎn)調(diào)試
- 在源碼中設(shè)置斷點(diǎn),選中需要設(shè)置代碼的那一行旋讹,在它的左側(cè)點(diǎn)擊一下會(huì)出現(xiàn)一個(gè)小紅點(diǎn)邑遏;
- 點(diǎn)擊
"調(diào)試"
圖標(biāo)或者調(diào)用Run -> Debug即可
1.創(chuàng)建flutter工程
Flutter Application(全新的APP)
flutter create flutter_app
#指定語言:默認(rèn)Android使用Java躺彬,iOS使用Objective-C
flutter create -i swift -a kotlin flutter_app
Flutter Module(混編到已有的Android/iOS工程)
flutter create -t module flutter_module
Flutter Package 只能用于 Dart 語言
flutter create --template=package flutter_package
Flutter Plugin 針對(duì)原生和Dart
- 默認(rèn)創(chuàng)建方式
flutter create --org com.example --template=plugin flutter_demo
- Objective-C 項(xiàng)目
flutter create --org com.example --template=plugin -i objc -a java flutter_demo
- Swift 項(xiàng)目
flutter create --org com.example --template=plugin -i swift -a kotlin flutter_demo
2.安裝依賴
Get package
flutter packages get
#如果不行可以設(shè)置國內(nèi)鏡像
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Update package
flutter packages upgrade
3.項(xiàng)目運(yùn)行
#列出所有連接的設(shè)備
flutter devices
#運(yùn)行項(xiàng)目并顯示支持設(shè)備
flutter run
#執(zhí)行設(shè)備運(yùn)行
flutter run -d 'iPhone X?'
#運(yùn)行在所有可用設(shè)備上
flutter run -d all
#查看可用模擬器
flutter emulators
#啟動(dòng)iOS模擬器
flutter emulators --launch apple_ios_simulator
#啟動(dòng)Android 模擬器-只有啟動(dòng)模擬器才可以運(yùn)行
flutter emulators --launch Nexus_5X_API_27
flutter run -d emulator-5554
#運(yùn)行IOS真機(jī)
flutter run -d 00008020-001838491169002E
調(diào)試
熱更新直接刷新
$ r
熱更新重啟刷新
$ R
退出運(yùn)行模擬器
$ q
查看日志
flutter logs
截圖
flutter screenshot
升級(jí)你的Flutter
flutter upgrade
或者
git stash
flutter upgrade --force
真機(jī)運(yùn)行
flutter run -d 73335b72c9ffd2154fafda7bb94e7c1c497336c3
安裝
flutter install
打包
Android apk 打包
flutter build apk
iOS ipa 打包
flutter build ios --debug
flutter build ios --release
編譯目錄:
項(xiàng)目工程目錄/build/ios/iphoneos/Runner.app
然后我們要?jiǎng)?chuàng)建一個(gè)名為Playload的文件夾,注意名字不能錯(cuò)溶推,然后把Runner.app粘貼到Playload文件下爱沟,然后對(duì)Playload壓縮成.zip:
然后將Playload.zip重命名為Playload.ipa:
Shell 腳本打包遺留目錄(dst)
cd /private/tmp/Runner.dst