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.

flutter create flutter init
๐Ÿš€

Running Apps

Commands to launch your Flutter app on connected devices, emulators, or web browsers for testing and development.

flutter run flutter devices
๐Ÿ”ง

Build & Deploy

Commands to compile your Flutter app into production-ready builds for Android, iOS, web, and desktop platforms.

flutter build flutter install
๐Ÿงช

Testing & Analysis

Commands to run unit tests, widget tests, analyze code quality, and ensure your app follows best practices.

flutter test flutter analyze

๐Ÿ”น 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

๐Ÿง  Test Your Knowledge

Which command checks your Flutter installation?