Flutter基本命令

1、 帮助命令
flutter -h

执行后内容显示为

Manage your Flutter app development.

Common commands:

  flutter create 
    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  [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.

    --packages              Path to your ".packages" file.
                            (required, since the current directory does not contain a ".packages" file)

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 " for more information about a command.
Run "flutter help -v" for verbose help output, including less commonly used options.
2、显示本机的模拟器
flutter emulators

执行后内容显示为

2 available emulators:

Pixel_2_API_28      • pixel_2       • Google • Pixel 2 API 28
apple_ios_simulator • iOS Simulator • Apple

To run an emulator, run 'flutter emulators --launch '.
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
3、启动本机的模拟器
flutter emulator --launch apple_ios_simulator

启动后可以看到模拟器打开了

4、远程更新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文件不在根目录下,这时候需要执行cd命令到工程目录

cd 工程目录
5、运行应用到模拟器上
flutter run

执行后应用将安装到模拟器中,并打开

6、热重载

先保存代码commad+s
然后在 terminal中输入r
执行后界面内容更新

7、停止运行
control+z

VSCode中常用的快捷键

R 键重新启动
r 键热重载
q 退出
p 显示网格
P 显示帧率
o 切换Android与iOS的预览模式

你可能感兴趣的:(Flutter基本命令)