Flutter Create New Project: Complete Command Syntax and Options
The correct syntax for creating a new Flutter project is flutter create <output-directory>, with optional flags for organization, platforms, and templates defined in the Flutter tool's source code.
When building a new application using the official Flutter documentation, understanding the precise syntax for the flutter create new project command ensures you scaffold projects correctly from the start. The command is implemented in the flutter/flutter repository and provides extensive customization options through command-line flags.
Core Syntax for Flutter Create New Project
Minimal Command Structure
According to the source code in packages/flutter_tools/lib/src/commands/create.dart, the invocation string follows this pattern:
${runner?.executableName} $name <output directory>
This translates to the minimal syntax:
flutter create <output-directory>
Where <output-directory> specifies the folder that will contain your new Flutter project. Use a single dot . to create the project in the current directory.
Command Implementation in Source Code
The CreateCommand class extends FlutterCommand and is registered in the Flutter CLI runner. The command parses arguments and constructs project files based on the specified template. Key implementation details reside in:
packages/flutter_tools/lib/src/commands/create.dart(lines 48-66): Defines all command-line options and flagspackages/flutter_tools/lib/src/commands/create_base.dart: Provides shared logic for template rendering and context buildingpackages/flutter_tools/lib/src/runner/flutter_command_runner.dart(line 61): Registers the command and provides help output generation
Common Options and Flags
The flutter create new project command supports extensive customization through flags defined in the create.dart source file.
Project Configuration Options
| Option | Description | Example |
|---|---|---|
--org |
Organization identifier in reverse-domain notation for Android package names and iOS bundle identifiers. Default: com.example. |
--org com.mycompany |
--project-name |
Dart-compatible project name (valid package identifier). | --project-name my_cool_app |
--description |
Text for the description field in pubspec.yaml. Default: "A new Flutter project." |
--description "My first Flutter app" |
Platform and Template Selection
| Option | Description | Example |
|---|---|---|
--template (-t) |
Project template type: app, module, package, plugin, plugin_ffi, package_ffi. |
-t plugin |
--platforms |
Comma-separated list of platforms to support (android, ios, web, linux, macos, windows). | --platforms android,ios,web |
--android-language |
Android programming language: java or kotlin. Default: kotlin. |
--android-language java |
--ios-language |
iOS programming language: objc or swift. Default: swift. |
--ios-language swift |
--sample (-s) |
Use a code sample from Flutter documentation as main.dart. |
-s material.Scaffold |
--empty (-e) |
Create minimal main.dart without comments. |
-e |
--overwrite |
Overwrite existing files when recreating a project. | --overwrite |
Practical Examples
Here are runnable examples demonstrating the flutter create new project syntax:
# Create a simple app in a new folder called my_app
flutter create my_app
# Create the app in the current directory
flutter create .
# Specify custom organization and project name
flutter create --org com.mycompany --project-name fancy_app .
# Generate a plugin supporting Android, iOS, and web
flutter create -t plugin --platforms android,ios,web my_plugin
# Start with a sample from the documentation
flutter create -s material.Scaffold my_sample_app
Key Source Files
Understanding the implementation of flutter create new project requires examining these files in the flutter/flutter repository:
| File | Role |
|---|---|
packages/flutter_tools/lib/src/commands/create.dart |
Implements CreateCommand, defines all flags and options, constructs the invocation string. |
packages/flutter_tools/lib/src/commands/create_base.dart |
Provides shared logic for template rendering, context building, and file generation across app, plugin, and package creation. |
packages/flutter_tools/lib/src/runner/flutter_command_runner.dart |
Registers the create command with the Flutter CLI and handles help output generation. |
packages/flutter_tools/templates/app/ |
Contains skeletal files for application projects. |
packages/flutter_tools/templates/plugin/ |
Contains template files for plugin development. |
Summary
- The minimal syntax for
flutter create new projectisflutter create <output-directory>, where you can use.for the current directory. - The command implementation resides in
packages/flutter_tools/lib/src/commands/create.dart, specifically lines 48-66 for option definitions. - Key configuration flags include
--orgfor package naming,--project-namefor Dart compatibility, and--platformsfor multi-platform support. - Template types (
-t) allow creating apps, modules, packages, or plugins with appropriate scaffolding. - Use
--sampleto bootstrap projects with official documentation examples or--emptyfor minimal starting code.
Frequently Asked Questions
What is the basic syntax for flutter create new project?
The basic syntax is flutter create <output-directory>, where <output-directory> is the folder name for your new project. To create the project in the current directory, use flutter create . with a single dot as the output directory.
How do I specify multiple platforms when creating a Flutter project?
Use the --platforms flag followed by a comma-separated list of platform names. For example: flutter create --platforms android,ios,web my_app. This flag works with the default app template and plugin templates to generate platform-specific configuration files.
Can I create a Flutter project with a specific code sample from the documentation?
Yes, use the --sample (or -s) flag followed by the sample ID from the Flutter documentation. For example: flutter create -s material.Scaffold my_app. This creates a new project with the specified sample code as the main.dart file, automatically implying the app template.
What is the difference between the app and plugin templates in flutter create?
The app template (default) scaffolds a standard Flutter application with a lib/main.dart entry point and platform folders for running on devices. The plugin template (-t plugin) creates a federated plugin project structure with platform-specific implementations, example apps, and proper pubspec configuration for publishing reusable functionality to pub.dev.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →