Ensure you have the following installed before proceeding:
- Flutter SDK (Flutter 3.19.5 • channel stable): Installation Guide
- Dart SDK (usually comes with Flutter)
- An IDE such as XCode, Android Studio, IntelliJ, or VS Code with Flutter and Dart plugins
Before building the app, you need to install all the required dependencies. This is done using the following command:
flutter pub get
This command fetches all the packages listed in your pubspec.yaml
file and installs them in your project. It's similar to npm install
in Node.js or pip install
in Python.
Flutter uses code generation for various tasks, such as generating JSON serialization code, Hive adapters, or any other generated files. To run the code generation, use the build_runner
package with the following command:
flutter pub run build_runner build --delete-conflicting-outputs
build_runner build
: This command generates the necessary files based on your annotations and configuration.--delete-conflicting-outputs
: This flag ensures that any conflicting files generated by previous runs are deleted before generating new ones. It helps avoid issues with stale or duplicate generated files.
Now, you can run your Flutter application using the following command:
flutter run
This command compiles your Flutter app and installs it on the connected device or emulator. If you have multiple devices connected, you may be prompted to select one.
- To view detailed logs while running the app, use
flutter run -v
. - If you need to clean the project (e.g., to fix build issues), use
flutter clean
and then repeat the steps above. - To run the app in release mode for better performance, use
flutter run --release
.