Whether you’re just starting out or building production-grade apps, the Flutter CLI is your best friend. It lets you manage projects, build apps, run tests, and deployβall from your terminal.
This guide categorizes and explains all the important Flutter CLI commands youβll need from project creation to deployment.
π 1. Project Setup Commands
These commands help you create and configure new Flutter projects.
π¨ flutter create
What it does:
Creates a new Flutter project in the specified directory.
When to use:
When starting a new Flutter app, plugin, or package.
Example usage:
flutter create my_app
Output/Effect:
Creates a complete Flutter project structure in the my_app
directory, including lib/
, pubspec.yaml
, test/
, etc.
βοΈ flutter config
What it does:
Shows or sets Flutter configuration options.
When to use:
To enable/disable features like web or desktop support.
Example usage:
flutter config --enable-web<br>
Output/Effect:
Updates Flutter settings. You can also run flutter config
to see current configurations.
π§ͺ 2. Development & Testing Commands
Commands in this section help you run your app and test its behavior during development.
βΆοΈ flutter run
What it does:
Builds and launches your app on a connected device or emulator.
When to use:
To see your app in action during development.
Example usage:
flutter run
Output/Effect:
Starts the app on a connected device or simulator. Supports hot reload for fast iteration.
π flutter pub get
What it does:
Downloads the packages listed in your pubspec.yaml
.
When to use:
After adding a new dependency.
Example usage:
flutter pub get
Output/Effect:
Creates or updates the .packages
and .flutter-plugins
files with necessary packages.
π§Ή flutter clean
What it does:
Deletes the build/ and temporary files.
When to use:
When your build gets buggy or you want to free up disk space.
Example usage:
flutter clean
Output/Effect:
Cleans the project by deleting temporary and intermediate files.
π§ͺ flutter test
What it does:
Runs unit and widget tests in your Flutter project.
When to use:
To ensure your code behaves as expected.
Example usage:
flutter test
Output/Effect:
Displays pass/fail results for all test files under test/
.
π οΈ 3. Build & Release Commands
These commands prepare your app for production or deployment.
ποΈ flutter build
What it does:
Builds your Flutter app for the specified platform.
When to use:
When preparing a release version of your app.
Example usage:
flutter build apk
flutter build ios
flutter build web
Output/Effect:
Generates platform-specific build files like .apk
, .ipa
, or web files in the build/
directory.
π flutter analyze
What it does:
Analyzes your Dart code for errors and warnings.
When to use:
Before pushing your code to ensure itβs clean and follows best practices.
Example usage:
flutter analyze
Output/Effect:
Displays suggestions, errors, and warnings about code issues.
π 4. Device & Emulator Management
Use these commands to manage connected devices and emulators.
π± flutter devices
What it does:
Lists all connected devices and available emulators.
When to use:
To verify your device is connected properly.
Example usage:
flutter devices
Output/Effect:
Prints a list of available devices with names, platforms, and SDK versions.
π² flutter emulators
What it does:
Lists and manages Android emulators.
When to use:
To view and launch your emulators.
Example usage:
flutter emulators
flutter emulators --launch Pixel_5_API_30
Output/Effect:
Shows available emulators and optionally starts one.
π 5. Version & Upgrade Management
Useful for managing Flutter SDK versions and dependencies.
πΌ flutter upgrade
What it does:
Updates Flutter to the latest stable version.
When to use:
To get the latest improvements, fixes, and features.
Example usage:
flutter upgrade
Output/Effect:
Downloads and installs the latest stable Flutter version.
π flutter downgrade
What it does:
Downgrades Flutter to the previous version.
When to use:
When a new version breaks your build and you need to revert.
Example usage:
flutter downgrade
Output/Effect:
Switches to the previously used Flutter version.
π§° 6. Project Maintenance & Tools
Commands that give you insight into your Flutter environment or help with debugging.
π₯οΈ flutter doctor
What it does:
Checks your environment and shows any missing dependencies.
When to use:
Right after installing Flutter or when something isnβt working.
Example usage:
flutter doctor
Output/Effect:
Displays setup status and alerts for missing components like Android Studio or SDKs.
π¦ flutter pub outdated
What it does:
Checks your dependencies for outdated versions.
When to use:
To update to newer versions of packages.
Example usage:
flutter pub outdated
Output/Effect:
Lists current, compatible, and latest versions of your packages.
π¨ flutter create
& flutter create .
π§± What They Do:
flutter create my_app
Creates a brand new Flutter project inside a new folder calledmy_app
.flutter create .
Initializes a new Flutter project in the current directory (instead of creating a new folder).
π When & Why to Use Them:
Command | When to Use |
---|---|
flutter create my_app | When starting a new project from scratch in a new directory. |
flutter create . | When you already have a folder (e.g., cloned from GitHub or manually created) and want to initialize it as a Flutter project. This is also helpful when regenerating missing files (e.g., pubspec.yaml , android/ , etc.). |
π Summary Table
Command | Category | Purpose |
---|---|---|
flutter create | Project Setup | Creates new Flutter app |
flutter config | Project Setup | Configures Flutter environment |
flutter run | Development | Runs app on connected device |
flutter pub get | Development | Fetches packages |
flutter clean | Development | Clears temporary files |
flutter test | Testing | Runs tests |
flutter build | Build & Release | Builds app for release |
flutter analyze | Build & Release | Checks for code issues |
flutter devices | Devices | Lists connected devices |
flutter emulators | Devices | Lists and manages emulators |
flutter upgrade | Versioning | Updates Flutter SDK |
flutter downgrade | Versioning | Downgrades Flutter SDK |
flutter doctor | Maintenance | Diagnoses environment |
flutter pub outdated | Maintenance | Shows outdated packages |
π Final Thoughts
The Flutter CLI is a powerful toolset that enables you to manage every part of your appβs lifecycle from your terminal. Whether youβre building, testing, or deploying, mastering these commands will make your development faster and more professional.