- cd 到flutter 的目錄下
- 幫助命令
flutter -h
執(zhí)行后內容顯示為
Manage 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 commands
executed.
If used with --help, shows hidden options.
-d, --device-id Target device id or name (prefixes allowed).
--version Reports the version of this tool.
--suppress-analytics Suppress analytics reporting when this command runs.
--bug-report Captures a bug report file to submit to the Flutter
team.
Contains local paths, device identifiers, and log
snippets.
Available commands:
analyze Analyze the project's Dart code.
attach Attach to a running application.
bash-completion Output command line shell completion setup scripts.
build Flutter build commands.
channel List or switch flutter channels.
clean Delete the build/ and .dart_tool/ directories.
config Configure Flutter settings.
create Create a new Flutter project.
devices List all connected devices.
doctor Show information about the installed tooling.
drive Runs Flutter Driver tests for the current project.
emulators List, launch and create emulators.
format Format one or more dart files.
help Display help information for flutter.
install Install a Flutter app on an attached device.
logs Show log output for running Flutter apps.
make-host-app-editable Moves host apps from generated directories to
non-generated directories so that they can be edited
by developers.
packages Commands for managing Flutter packages.
precache Populates the Flutter tool's cache of binary
artifacts.
run Run your Flutter app on an attached device.
screenshot Take a screenshot from a connected device.
stop Stop your Flutter app on an attached device.
test Run Flutter unit tests for the current project.
trace Start and stop tracing for a running Flutter app.
upgrade Upgrade your copy of Flutter.
version List or switch flutter versions.
Run "flutter help <command>" for more information about a command.
Run "flutter help -v" for verbose help output, including less commonly used
options.
3.顯示本機的模擬器
flutter emulators
執(zhí)行后顯示內容
2 available emulators:
Nexus_6_API_26 ? Nexus 6 ? Google ? Nexus 6 API 26
apple_ios_simulator ? iOS Simulator ? Apple
To run an emulator, run 'flutter emulators --launch <emulator id>'.
To create a new emulator, run 'flutter emulators --create [--name xyz]'.
You can find more information on managing emulators at the links below:
https://developer.android.com/studio/run/managing-avds
https://developer.android.com/studio/command-line/avdmanager
4.啟動本機的模擬器(當前啟動的是ios模擬器)
flutter emulator --launch apple_ios_simulator
5.遠程更新package
pubspec.yaml會依賴一些遠程庫侥蒙,這邊相當于將遠程的依賴下載到本地拣展。
flutter packages get
如果提示以下內容
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
Do not run this command from the root of your git clone of Flutter.
說明pubspec.yaml文件不在根目錄下捕儒,這時候需要執(zhí)行cd命令到工程目錄
6.運行應用到模擬器上
flutter run
7.熱重載
先保存代碼commad+s
然后在 terminal中輸入r
執(zhí)行后界面內容更新
8.停止運行
control+z
9.VSCode中常用的快捷鍵
R 鍵重新啟動
r 鍵熱重載
q 退出
p 顯示網格
P 顯示幀率
o 切換Android與iOS的預覽模式