1. flutter create -h

  1. $ flutter create -h
  2. Create a new Flutter project.
  3. If run on a project that already exists, this will repair the project, recreating any files that are missing.
  4. Global options:
  5. -h, --help Print this usage information.
  6. -v, --verbose Noisy logging, including all shell commands executed.
  7. If used with --help, shows hidden options.
  8. -d, --device-id Target device id or name (prefixes allowed).
  9. --version Reports the version of this tool.
  10. --suppress-analytics Suppress analytics reporting when this command runs.
  11. --packages Path to your ".packages" file.
  12. (required, since the current directory does not contain a ".packages" file)
  13. Usage: flutter create <output directory>
  14. -h, --help Print this usage information.
  15. --platforms The platforms supported by this project. This argument only works when the --template is set to app or plugin. Platform folders (e.g. android/) will be generated in the target project. When adding platforms to a plugin project, the pubspec.yaml will be updated with the requested platform. Adding desktop platforms requires the corresponding desktop config setting to be enabled.
  16. [ios (default), android (default), windows (default), linux (default), macos (default), web (default)]
  17. --[no-]pub Whether to run "flutter pub get" after the project has been created.
  18. (defaults to on)
  19. --[no-]offline When "flutter pub get" is run by the create command, this indicates whether to run it in offline mode or not. In offline mode, it will need to have all dependencies already available in the pub cache to succeed.
  20. --[no-]with-driver-test Also add a flutter_driver dependency and generate a sample 'flutter drive' test.
  21. -t, --template=<type> Specify the type of project to create.
  22. [app] (default) Generate a Flutter application.
  23. [module] Generate a project to add a Flutter module to an existing Android or iOS application.
  24. [package] Generate a shareable Flutter project containing modular Dart code.
  25. [plugin] Generate a shareable Flutter project containing an API in Dart code with a platform-specific implementation for Android, for iOS code, or for both.
  26. -s, --sample=<id> Specifies the Flutter code sample to use as the main.dart for an application. Implies --template=app. The value should be the sample ID of the desired sample from the API documentation website (http://docs.flutter.dev). An example can be found at https://master-api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html
  27. --list-samples=<path> Specifies a JSON output file for a listing of Flutter code samples that can be created with --sample.
  28. --[no-]overwrite When performing operations, overwrite existing files.
  29. --description The description to use for your new Flutter project. This string ends up in the pubspec.yaml file.
  30. (defaults to "A new Flutter project.")
  31. --org The organization responsible for your new Flutter project, in reverse domain name notation. This string is used in Java package names and as prefix in the iOS bundle identifier.
  32. (defaults to "com.example")
  33. --project-name The project name for this new Flutter project. This must be a valid dart package name.
  34. -i, --ios-language [objc, swift (default)]
  35. -a, --android-language [java, kotlin (default)]
  36. Run "flutter help" to see global options.

2. 常用参数

— org : 设置组织代号,一般用域名倒置写法,如’com.google’
— template :设置创建的形式,包括【app、module、package、plugin】
— platforms : 设置支持的平台。1.20版本后,创建plugin需要手动设置。
— i : 设置ios平台的语言
— a : 设置android平台语言

3. 常用命令组合

  1. 创建一个hello_world应用 ```shell $ flutter create hello_world Creating project hello_world… hello_world.gitignore (created) hello_world.idea\libraries\Dart_SDK.xml (created) hello_world.idea\libraries\KotlinJavaRuntime.xml (created) hello_world.idea\modules.xml (created) hello_world.idea\runConfigurations\main_dart.xml (created) hello_world.idea\workspace.xml (created) hello_world.metadata (created) hello_world\android\app\build.gradle (created) hello_world\android\app\src\main\kotlin\com\example\hello_world\MainActivity.kt (created) hello_world\android\build.gradle (created) hello_world\android\hello_world_android.iml (created) hello_world\android.gitignore (created) hello_world\android\app\src\debug\AndroidManifest.xml (created) hello_world\android\app\src\main\AndroidManifest.xml (created) hello_world\android\app\src\main\res\drawable\launch_background.xml (created) hello_world\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (created) hello_world\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created) hello_world\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (created) hello_world\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (created) hello_world\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (created) hello_world\android\app\src\main\res\values\styles.xml (created) hello_world\android\app\src\profile\AndroidManifest.xml (created) hello_world\android\gradle\wrapper\gradle-wrapper.properties (created) hello_world\android\gradle.properties (created) hello_world\android\settings.gradle (created) hello_world\ios\Runner\AppDelegate.swift (created) hello_world\ios\Runner\Runner-Bridging-Header.h (created) hello_world\ios\Runner.xcodeproj\project.pbxproj (created) hello_world\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (created) hello_world\ios.gitignore (created) hello_world\ios\Flutter\AppFrameworkInfo.plist (created) hello_world\ios\Flutter\Debug.xcconfig (created) hello_world\ios\Flutter\Release.xcconfig (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Contents.json (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-1024x1024@1x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@1x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@2x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@3x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@1x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@2x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@3x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@1x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@2x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@3x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@2x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@3x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@1x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@2x.png (created) hello_world\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-83.5x83.5@2x.png (created) hello_world\ios\Runner\Assets.xcassets\LaunchImage.imageset\Contents.json (created) hello_world\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage.png (created) hello_world\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@2x.png (created) hello_world\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@3x.png (created) hello_world\ios\Runner\Assets.xcassets\LaunchImage.imageset\README.md (created) hello_world\ios\Runner\Base.lproj\LaunchScreen.storyboard (created) hello_world\ios\Runner\Base.lproj\Main.storyboard (created) hello_world\ios\Runner\Info.plist (created) hello_world\ios\Runner.xcodeproj\project.xcworkspace\contents.xcworkspacedata (created) hello_world\ios\Runner.xcodeproj\project.xcworkspace\xcshareddata\IDEWorkspaceChecks.plist (created) hello_world\ios\Runner.xcodeproj\project.xcworkspace\xcshareddata\WorkspaceSettings.xcsettings (created) hello_world\ios\Runner.xcworkspace\contents.xcworkspacedata (created) hello_world\ios\Runner.xcworkspace\xcshareddata\IDEWorkspaceChecks.plist (created) hello_world\ios\Runner.xcworkspace\xcshareddata\WorkspaceSettings.xcsettings (created) hello_world\lib\main.dart (created) hello_world\hello_world.iml (created) hello_world\pubspec.yaml (created) hello_world\README.md (created) hello_world\test\widget_test.dart (created) Running “flutter pub get” in hello_world…
  1. 2. 创建一个名为 'example_app',组织为 'cn.yshye'iosobject-cAndroidkotlin的应用
  2. ```shell
  3. $ flutter create --org=cn.yshye -i objc -a kotlin example_app
  4. Creating project example_app...
  5. example_app\.gitignore (created)
  6. example_app\.idea\libraries\Dart_SDK.xml (created)
  7. example_app\.idea\libraries\KotlinJavaRuntime.xml (created)
  8. example_app\.idea\modules.xml (created)
  9. example_app\.idea\runConfigurations\main_dart.xml (created)
  10. example_app\.idea\workspace.xml (created)
  11. example_app\.metadata (created)
  12. example_app\android\app\build.gradle (created)
  13. example_app\android\app\src\main\kotlin\cn\yshye\example_app\MainActivity.kt (created)
  14. example_app\android\build.gradle (created)
  15. example_app\android\example_app_android.iml (created)
  16. example_app\android\.gitignore (created)
  17. example_app\android\app\src\debug\AndroidManifest.xml (created)
  18. example_app\android\app\src\main\AndroidManifest.xml (created)
  19. example_app\android\app\src\main\res\drawable\launch_background.xml (created)
  20. example_app\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (created)
  21. example_app\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created)
  22. example_app\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (created)
  23. example_app\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (created)
  24. example_app\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (created)
  25. example_app\android\app\src\main\res\values\styles.xml (created)
  26. example_app\android\app\src\profile\AndroidManifest.xml (created)
  27. example_app\android\gradle\wrapper\gradle-wrapper.properties (created)
  28. example_app\android\gradle.properties (created)
  29. example_app\android\settings.gradle (created)
  30. example_app\ios\Runner\AppDelegate.h (created)
  31. example_app\ios\Runner\AppDelegate.m (created)
  32. example_app\ios\Runner\main.m (created)
  33. example_app\ios\Runner.xcodeproj\project.pbxproj (created)
  34. example_app\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (created)
  35. example_app\ios\.gitignore (created)
  36. example_app\ios\Flutter\AppFrameworkInfo.plist (created)
  37. example_app\ios\Flutter\Debug.xcconfig (created)
  38. example_app\ios\Flutter\Release.xcconfig (created)
  39. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Contents.json (created)
  40. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-1024x1024@1x.png (created)
  41. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@1x.png (created)
  42. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@2x.png (created)
  43. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@3x.png (created)
  44. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@1x.png (created)
  45. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@2x.png (created)
  46. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@3x.png (created)
  47. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@1x.png (created)
  48. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@2x.png (created)
  49. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@3x.png (created)
  50. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@2x.png (created)
  51. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@3x.png (created)
  52. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@1x.png (created)
  53. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@2x.png (created)
  54. example_app\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-83.5x83.5@2x.png (created)
  55. example_app\ios\Runner\Assets.xcassets\LaunchImage.imageset\Contents.json (created)
  56. example_app\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage.png (created)
  57. example_app\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@2x.png (created)
  58. example_app\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@3x.png (created)
  59. example_app\ios\Runner\Assets.xcassets\LaunchImage.imageset\README.md (created)
  60. example_app\ios\Runner\Base.lproj\LaunchScreen.storyboard (created)
  61. example_app\ios\Runner\Base.lproj\Main.storyboard (created)
  62. example_app\ios\Runner\Info.plist (created)
  63. example_app\ios\Runner.xcodeproj\project.xcworkspace\contents.xcworkspacedata (created)
  64. example_app\ios\Runner.xcodeproj\project.xcworkspace\xcshareddata\IDEWorkspaceChecks.plist (created)
  65. example_app\ios\Runner.xcodeproj\project.xcworkspace\xcshareddata\WorkspaceSettings.xcsettings (created)
  66. example_app\ios\Runner.xcworkspace\contents.xcworkspacedata (created)
  67. example_app\ios\Runner.xcworkspace\xcshareddata\IDEWorkspaceChecks.plist (created)
  68. example_app\ios\Runner.xcworkspace\xcshareddata\WorkspaceSettings.xcsettings (created)
  69. example_app\lib\main.dart (created)
  70. example_app\example_app.iml (created)
  71. example_app\pubspec.yaml (created)
  72. example_app\README.md (created)
  73. example_app\test\widget_test.dart (created)
  74. Running "flutter pub get" in example_app...
  1. 创建一个名为‘example_plugin’,组织为‘cn.yshye’,ios用object-c,Android用kotlin的插件,支持iso和Android平台

    1. $ flutter create --org=cn.yshye -i objc -a kotlin --template=plugin --platforms=android,ios example_plugin
    2. Creating project example_plugin...
    3. example_plugin\.gitignore (created)
    4. example_plugin\.idea\libraries\Dart_SDK.xml (created)
    5. example_plugin\.idea\modules.xml (created)
    6. example_plugin\.idea\runConfigurations\example_lib_main_dart.xml (created)
    7. example_plugin\.idea\workspace.xml (created)
    8. example_plugin\.metadata (created)
    9. example_plugin\android\build.gradle (created)
    10. example_plugin\android\example_plugin_android.iml (created)
    11. example_plugin\android\src\main\kotlin\cn\yshye\example_plugin\ExamplePlugin.kt (created)
    12. example_plugin\android\.gitignore (created)
    13. example_plugin\android\gradle\wrapper\gradle-wrapper.properties (created)
    14. example_plugin\android\gradle.properties (created)
    15. example_plugin\android\settings.gradle (created)
    16. example_plugin\android\src\main\AndroidManifest.xml (created)
    17. example_plugin\CHANGELOG.md (created)
    18. example_plugin\ios\Classes\ExamplePlugin.h (created)
    19. example_plugin\ios\Classes\ExamplePlugin.m (created)
    20. example_plugin\ios\example_plugin.podspec (created)
    21. example_plugin\ios\.gitignore (created)
    22. example_plugin\ios\Assets\.gitkeep (created)
    23. example_plugin\lib\example_plugin.dart (created)
    24. example_plugin\LICENSE (created)
    25. example_plugin\example_plugin.iml (created)
    26. example_plugin\pubspec.yaml (created)
    27. example_plugin\README.md (created)
    28. example_plugin\test\example_plugin_test.dart (created)
    29. Running "flutter pub get" in example_plugin...
  2. 创建一个名为‘example_package’,组织为‘cn.yshye’,纯dart工具包。 ```shell $ flutter create —org=cn.yshye —template=package example_package Creating project example_package… example_package.gitignore (created) example_package.idea\libraries\Dart_SDK.xml (created) example_package.idea\modules.xml (created) example_package.idea\workspace.xml (created) example_package.metadata (created) example_package\CHANGELOG.md (created) example_package\lib\example_package.dart (created) example_package\LICENSE (created) example_package\example_package.iml (created) example_package\pubspec.yaml (created) example_package\README.md (created) example_package\test\example_package_test.dart (created) Running “flutter pub get” in example_package…

```