Flutter CLI Commands
Essential command-line tools for Flutter development
โก What are Flutter CLI Commands?
Flutter CLI commands are terminal instructions that help you create, build, test, and manage Flutter applications efficiently. These commands streamline your development workflow and automate common tasks.
# Check Flutter installation
flutter doctor
# Create a new Flutter project
flutter create my_app
Essential Flutter Commands
Project Creation
Commands to create and initialize new Flutter projects with different templates and configurations for various platforms.
Running Apps
Commands to launch your Flutter app on connected devices, emulators, or web browsers for testing and development.
Build & Deploy
Commands to compile your Flutter app into production-ready builds for Android, iOS, web, and desktop platforms.
Testing & Analysis
Commands to run unit tests, widget tests, analyze code quality, and ensure your app follows best practices.
๐น Getting Started Commands
Essential commands every Flutter developer should know:
๐ธ Check Flutter Installation
# Verify Flutter setup and dependencies
flutter doctor
# Get detailed information
flutter doctor -v
What it does: Checks your Flutter installation, identifies missing dependencies, and suggests fixes.
๐ธ Create a New Project
# Create a basic Flutter app
flutter create my_app
# Create with specific organization
flutter create --org com.example my_app
# Create with template
flutter create --template=plugin my_plugin
What it does: Generates a new Flutter project with all necessary files and folder structure.
๐น Running & Testing Commands
๐ธ Run Your App
# Run on connected device
flutter run
# Run in debug mode
flutter run --debug
# Run in release mode
flutter run --release
# Run on specific device
flutter run -d chrome
๐ธ List Available Devices
# Show all connected devices
flutter devices
# Example output:
# Chrome (web) โข chrome โข web-javascript
# Android SDK (mobile) โข emulator-5554 โข android
๐ธ Hot Reload & Restart
While your app is running:
- r - Hot reload (updates UI instantly)
- R - Hot restart (restarts app)
- q - Quit the app
๐น Build Commands
Compile your app for different platforms:
๐ธ Build for Android
# Build APK
flutter build apk
# Build App Bundle (recommended for Play Store)
flutter build appbundle
# Build for specific architecture
flutter build apk --split-per-abi
๐ธ Build for iOS
# Build iOS app
flutter build ios
# Build without code signing
flutter build ios --no-codesign
๐ธ Build for Web
# Build web app
flutter build web
# Build with specific renderer
flutter build web --web-renderer html
๐น Package Management
๐ธ Manage Dependencies
# Get all dependencies
flutter pub get
# Update dependencies
flutter pub upgrade
# Add a new package
flutter pub add http
# Remove a package
flutter pub remove http
๐ธ Clean Project
# Clean build files
flutter clean
# Useful when facing build issues
๐น Testing & Analysis Commands
๐ธ Run Tests
# Run all tests
flutter test
# Run specific test file
flutter test test/widget_test.dart
# Run with coverage
flutter test --coverage
๐ธ Analyze Code
# Analyze code for issues
flutter analyze
# Format code
flutter format lib/
# Check for outdated packages
flutter pub outdated
๐น Useful Utility Commands
# Check Flutter version
flutter --version
# Upgrade Flutter SDK
flutter upgrade
# Switch Flutter channel
flutter channel stable
flutter channel beta
# Generate app icons
flutter pub run flutter_launcher_icons
# Take screenshot from running app
flutter screenshot
๐น Quick Reference Table
| Command | Purpose |
|---|---|
flutter doctor
|
Check installation |
flutter create app_name
|
Create new project |
flutter run
|
Run app on device |
flutter pub get
|
Install dependencies |
flutter build apk
|
Build Android APK |
flutter clean
|
Clean build files |