Flutter has revolutionized app development with its cross-platform capabilities and a wide range of features. However, the real magic lies in mastering its commands. These commands streamline development, manage dependencies, and build production-ready apps.
![]() |
Flutter Useful Commands |
Here’s a complete guide to the most important Flutter commands, including advanced tools like flutter pub
, build_runner
, and more.
1. Setting Up and Diagnosing
Check System Setup
flutter doctor
flutter doctor --verbose
Create a New Project
Start a fresh Flutter project with a single command.
flutter create project_name
flutter create project_name --org "domain_name_reversed"
Or, you can create empty project , by adding -e flag. It will give the project without the counter app
flutter create -e project_name
You can customize the template using flags like --org , --template , -e , --empty. Use platform specified command like this for your next project.
flutter create -e your_app_name --platforms android,ios --org "com.your_organization"
Create Plugin & Packages
flutter create --template=package package_name
flutter create --org com.example --template=plugin --platforms=android,ios,linux,macos,windows -a kotlin package_name
Run the App
flutter run
Launch your Flutter app on a connected device or emulator. Add -d to specify a device.
flutter run -d chrome
2. Dependency Management
Add a Package
flutter pub add package_name
This command directly adds a dependency to your pubspec.yaml file and fetches it.
Get Packages
flutter pub get
Fetches all dependencies listed in your pubspec.yaml.
Upgrade Dependencies
flutter pub upgrade
Updates all dependencies to their latest compatible versions.
Resolve Conflicts
flutter pub outdated
Lists outdated dependencies, helping you decide which ones to update.
3. Advanced Code Generation with build_runner
The build_runner package is a powerful tool for generating code, commonly used with libraries like freezed, json_serializable, or injectable.
Run Code Generators
flutter pub run build_runner build
Generates necessary files, such as models, serializers, or dependency injections.
Watch for Changes
flutter pub run build_runner watch
Clean Build Cache
flutter pub run build_runner clean
4. Building for Production
Build APK
flutter build apk --release
Generates a release APK for Android. Use --split-per-abi for smaller APKs.
Build AppBundle
flutter build appbundle --release
Build for iOS
flutter build ios --release
Compiles the app for iOS devices. Requires macOS and Xcode.
5. Maintenance and Cleanup
Clear Project Cache
flutter clean
Deletes temporary files to resolve build issues.
6. Testing and Linting
Run Tests
flutter test
Executes all unit and widget tests.
Analyze Code
flutter analyze
Checks your code for potential issues.
Format Code
flutter format .
Applies Dart's official formatting rules to your codebase.
8. Other Useful Commands
Install Android Licenses
flutter doctor --android-licenses
Accepts necessary licenses for Android development.
Generate Localizations
flutter pub run intl_utils:generate
Check Version Information
flutter --version
Displays the installed Flutter version and Dart SDK.
Conclusion
Mastering Flutter commands is essential for efficient app development. From managing dependencies to building production-ready apps, these commands empower developers to create robust applications with ease. Save this guide as a reference and elevate your Flutter development skills.
If you found this guide helpful, share it with your developer community or leave your thoughts in the comments below. Keep coding and happy Fluttering!