Flutter is a powerful framework for building cross-platform applications. This guide provides essential commands, important packages, common issues, and their solutions to help you master Flutter development.
flutter doctor # Checks Flutter installation and dependencies
flutter doctor --android-licenses # Command: Accept Android Licenses
flutter create my_app # Creates a new Flutter project
flutter run # Runs the app on a connected device or emulator
flutter build apk # Builds an APK for Android
flutter build ios # Builds an iOS app
flutter clean # Clears the build cache
flutter pub get # Fetches dependencies from pubspec.yaml
flutter pub upgrade # Updates dependencies to the latest versions
flutter analyze # Analyzes the project for potential issues
flutter format . # Formats all Dart files in the project
flutter test # Runs tests in the project
dart --version # Checks Dart version
dart run file.dart # Runs a specific Dart file
dart analyze # Analyzes Dart code for errors and warnings
dart fix --apply # Removes unused imports and cleans codeflutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abiExplanation:
- Builds separate APKs for different architectures (arm, arm64, x64).
--split-per-abiensures optimized APKs for specific CPU architectures, reducing APK size.- Useful for Play Store deployment to ensure users download only the compatible APK.
cd android && ./gradlew clean # Cleans the Gradle build cache
cd android && ./gradlew build # Builds the Android project
cd android && ./gradlew dependencies # Lists dependencies and resolves conflicts
cd android && ./gradlew --stop # Stops all Gradle daemons
cd android && ./gradlew --refresh-dependencies # Forces dependency refresh
cd android && ./gradlew clean assembleDebug # Compiles the app in debug modegit init # Initializes a new Git repository
git clone <repo_url> # Clones an existing Git repository
git status # Shows the current status of your working directory
git add . # Adds all changes to the staging area
git commit -m "message" # Commits the staged changes with a message
git push origin <branch> # Pushes committed changes to the remote repository
git pull origin <branch> # Fetches and merges changes from the remote repository
git branch # Lists all branches in the repository
git checkout <branch> # Switches to a different branch
git merge <branch> # Merges the specified branch into the current branchflutter pub global activate msix
flutter build windows --release
dart pub global run msix:createprovider- Recommended approach for state management.riverpod- A powerful alternative to provider.bloc- Business logic component for structured state management.get- Simple and efficient state management solution.
http- Simple package for REST API requests.dio- Advanced HTTP client with interceptors and error handling.graphql_flutter- For integrating GraphQL in Flutter.
sqflite- SQLite plugin for local database storage.hive- Lightweight and fast key-value database.shared_preferences- Store small amounts of persistent data.firebase_core&cloud_firestore- Firebase Firestore for cloud storage.
flutter_svg- SVG image support.cached_network_image- Caches images for performance.lottie- Adds Lottie animations.flutter_screenutil- Helps with responsive UI design.
firebase_auth- Firebase authentication support.google_sign_in- Google login integration.flutter_facebook_auth- Facebook login integration.sign_in_with_apple- Apple login support.
flutter_local_notifications- Local push notifications.geolocator- Fetch device location.url_launcher- Open URLs, emails, or phone calls.flutter_native_splash- Custom splash screens.
✅ Solution: Ensure main() calls WidgetsFlutterBinding.ensureInitialized().
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}✅ Solution: Run flutter pub get.
✅ Solution: Run flutter clean followed by flutter run.
✅ Solution:
- Ensure
android/gradle/wrapper/gradle-wrapper.propertieshas a compatible Gradle version. - Run
flutter doctorand resolve missing dependencies.
✅ Solution:
- Ensure Xcode is installed and updated.
- Run
pod installinsideios/directory.
✅ Solution:
- Make sure
GoogleService-Info.plistis correctly placed inios/Runner/. - Add
use_frameworks!in thePodfileand runpod install.
✅ Solution:
- Add required permissions in
AndroidManifest.xml(for Android) andInfo.plist(for iOS).
✅ Solution: Ensure that the keystore.jks file exists and the path is correct in key.properties.
✅ Solution: Double-check the storePassword and keyPassword in key.properties and ensure they match the actual keystore.
✅ Solution:
android {
signingConfigs {
release {
storeFile file("../keystore.jks")
storePassword "your_password"
keyAlias "your_key_alias"
keyPassword "your_key_password"
}
}
}✅ Solution: Run the following command to list key aliases in your keystore:
keytool -list -v -keystore your_keystore.jks✅ Solution: Get the correct fingerprint using:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android✅ Solution: Ensure your app is signed with the correct upload key and matches the Play Console key.
✅ Solution: Run the following command to verify the signature:
jarsigner -verify -verbose -certs your_app.apk<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><key>NSCameraUsageDescription</key>
<string>We need camera access</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location</string>Changing the package name in a Flutter project is a crucial step when customizing your application. You can easily achieve this using the change_app_package_name package or by manually updating the necessary files.
This is the simplest and fastest method.
Run the following command in your terminal:
flutter pub add change_app_package_nameRun the command below, replacing com.new.package.name with your desired package name:
flutter pub run change_app_package_name:main com.new.package.nameThis command will automatically update all necessary files.
After running the command, check that the following files have been updated:
android/app/src/main/AndroidManifest.xmlandroid/app/build.gradleandroid/app/src/main/kotlin/com/new/package/name/MainActivity.kt(if using Kotlin)android/app/src/main/java/com/new/package/name/MainActivity.java(if using Java)ios/Runner.xcodeproj/project.pbxprojios/Runner/Info.plist
Run the following commands to apply the changes:
flutter clean
flutter pub get
flutter runFor greater control, you can manually update the package name by modifying key project files.
- Open
android/app/src/main/AndroidManifest.xmland change thepackageattribute:<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.new.package.name">
- Update
android/app/build.gradle:android { defaultConfig { applicationId "com.new.package.name" } }
- Rename the folder structure inside
android/app/src/main/kotlin/(orjava/) to match the new package name.
- Open
ios/Runner.xcodeprojin Xcode. - Go to
Runner>General>Identityand change theBundle Identifier. - Update
ios/Runner/Info.plist:<key>CFBundleIdentifier</key> <string>com.new.package.name</string>
After making these changes, run:
flutter clean
flutter pub get
flutter runThis ensures that the new package name is applied successfully and your Flutter project is configured correctly.
Flutter allows developers to build high-performance applications for Windows. This guide provides a detailed step-by-step approach to setting up, building, and optimizing a Windows app using Flutter.
Before you start, ensure your system meets the following requirements:
- ✔ Windows 10 or later (64-bit)
- ✔ PowerShell 5.0 or later
- ✔ Git for Windows
- ✔ Visual Studio 2022 (with C++ development tools)
- ✔ Flutter SDK (latest stable version)
Download and extract Flutter from the official site:
https://flutter.dev/docs/get-started/install/windowsAdd Flutter to the system path and verify the installation with:
flutter doctorEnsure there are no missing dependencies.
Run the following command to enable Windows development in Flutter:
flutter config --enable-windows-desktopCheck if Windows support is enabled by running:
flutter doctorIf everything is correctly set up, you should see Windows (desktop) listed as a supported platform.
Create a new Flutter project with:
flutter create my_windows_app
cd my_windows_appTo confirm Windows support, list available devices:
flutter devicesTo run your Windows Flutter app:
flutter run -d windowsIf you encounter issues, try:
flutter clean
flutter pub get
flutter run -d windowsThis is the entry point for the Windows app. You can modify it to adjust behavior or add native functionality.
Replace windows/runner/resources/app_icon.ico with your own icon.
Then, modify windows/CMakeLists.txt to reference the new icon.
Edit windows/runner/main.cpp and modify the CreateAndShowWindow function:
window.CreateAndShow(L"My Windows App", {100, 100, 800, 600});Once development is complete, build the Windows executable:
flutter build windowsThis creates an executable in build/windows/runner/Release/.
You can package the app into an installer using NSIS or Inno Setup:
- ✨ NSIS: https://nsis.sourceforge.io/
- ✨ Inno Setup: https://jrsoftware.org/isinfo.php
Alternatively, zip the build/windows/runner/Release/ folder and share it directly.
✅ Solution:
- Ensure all dependencies are installed (
flutter doctor) - Try running
flutter cleanfollowed byflutter build windows
✅ Solution:
- Run
flutter doctorto check if Windows support is enabled. - If missing, enable it using
flutter config --enable-windows-desktop.
✅ Solution:
- Ensure you are using
releasemode for better performance:flutter build windows --release
- Optimize UI rendering using
constwidgets where possible.
- ✨ Use Platform Channels to interact with Windows-specific APIs.
- ✨ Optimize state management with
providerorriverpod. - ✨ Implement error logging with
sentry_flutter. - ✨ Ensure the UI is responsive for different window sizes.
- Use const for widgets that don’t change to improve performance.
- Organize code into separate files for readability.
- Optimize app size by using WebP images instead of PNGs.
- Write unit and widget tests using flutter_test package.
Flutter is an ever-evolving framework, and mastering its commands, packages, and debugging techniques will help you build efficient, scalable applications. Keep experimenting and stay updated with new features! 🚀