A Flutter-based gallery application with multi-flavor support for development and production environments.
A cross-platform gallery application built with Flutter, featuring clean architecture, state management with BLoC, and local caching capabilities.
- Flutter SDK: ^3.5.2
- Dart: ^3.5.2
- flutter_bloc: ^9.1.1 - BLoC pattern for state management
- get_it: ^7.7.0 - Service locator for dependency injection
- equatable: ^2.0.5 - Value equality for Dart classes
- dio: ^5.7.0 - HTTP client for API calls
- retrofit: ^4.4.1 - Type-safe REST client
- pretty_dio_logger: ^1.4.0 - Network request logging
- connectivity_plus: ^7.0.0 - Network connectivity monitoring
- hive: ^2.2.3 - Lightweight NoSQL database
- hive_flutter: ^1.1.0 - Flutter integration for Hive
- shared_preferences: ^2.3.2 - Key-value storage
- cached_network_image: ^3.2.0 - Image caching
- loading_animation_widget: ^1.2.0 - Loading animations
- flutter_staggered_grid_view: ^0.7.0 - Staggered grid layouts
- pull_to_refresh: ^2.0.0 - Pull-to-refresh functionality
- cupertino_icons: ^1.0.8 - iOS-style icons
- go_router: ^14.2.8 - Declarative routing
- flutter_dotenv: ^6.0.0 - Environment variable management
- build_runner: ^2.4.13 - Code generation
- json_serializable: ^6.8.0 - JSON serialization
- retrofit_generator: ^8.2.1 - Retrofit code generation
- hive_generator: ^2.0.1 - Hive type adapters generation
- flutter_lints: ^4.0.0 - Linting rules
gallery/
βββ android/ # Android native code
β βββ app/
β β βββ src/ # Android source files
β β βββ build.gradle.kts # App-level Gradle config
β β βββ flavorizr.gradle.kts # Flavor configurations
β βββ build.gradle.kts # Project-level Gradle config
β βββ settings.gradle.kts # Gradle settings
β
βββ ios/ # iOS native code
β βββ Runner/ # iOS app files
β βββ Runner.xcodeproj/ # Xcode project
β
βββ lib/
β βββ main.dart # Main entry point
β βββ main_dev.dart # Development entry point
β βββ main_prod.dart # Production entry point
β βββ app.dart # App widget
β βββ flavors.dart # Flavor configurations
β β
β βββ config/ # Configuration files
β β βββ app/ # App configurations
β β βββ flavorizr/ # Flavorizr configurations
β β
β βββ core/ # Core application logic
β β βββ constants/ # App constants
β β βββ di/ # Dependency injection setup
β β βββ network/ # Network configurations
β β βββ routes/ # Routing configuration
β β βββ services/ # Core services
β β βββ theme/ # App theme
β β
β βββ features/ # Feature modules
β βββ data/ # Data layer (repositories, models, data sources)
β βββ presentation/ # Presentation layer (UI, BLoC)
β
βββ assets/
β βββ icons/ # App icons
β βββ images/ # Image assets
β
βββ test/ # Unit and widget tests
β βββ widget_test.dart
β
βββ .env # Environment variables
βββ pubspec.yaml # Flutter dependencies
βββ analysis_options.yaml # Dart analyzer configuration
βββ README.md # Project documentation
The project follows Clean Architecture principles with separation of concerns:
- Presentation Layer: UI components and BLoC state management
- Domain Layer: Business logic and use cases
- Data Layer: Repositories, data sources, and models
- Flutter SDK (^3.5.2 or higher)
- Dart SDK (^3.5.2 or higher)
- Android Studio / Xcode (for platform-specific builds)
-
Clone the repository
git clone <repository-url> cd gallery
-
Install dependencies
flutter pub get
-
Generate code (for models, repositories, etc.)
flutter pub run build_runner build --delete-conflicting-outputs
-
Configure environment variables
- Create a
.envfile in the root directory - Add necessary API keys and configurations
- Create a
The app uses Flutter Flavorizr for managing multiple build flavors (Development & Production).
Android APK:
flutter build apk --release --flavor development -t lib/main_dev.dartiOS:
flutter build ios --release --flavor development -t lib/main_dev.dartRun on device:
flutter run --flavor development -t lib/main_dev.dartAndroid APK:
flutter build apk --release --flavor production -t lib/main_prod.dartAndroid App Bundle (for Play Store):
flutter build appbundle --release --flavor production -t lib/main_prod.dartiOS:
flutter build ios --release --flavor production -t lib/main_prod.dartRun on device:
flutter run --flavor production -t lib/main_prod.dart- Android APK:
build/app/outputs/flutter-apk/app-{flavor}-release.apk - Android Bundle:
build/app/outputs/bundle/{flavor}Release/app-{flavor}-release.aab - iOS:
build/ios/iphoneos/Runner.app
The app supports two flavors:
| Flavor | Application ID | App Name |
|---|---|---|
| Development | com.example.myapp.dev |
Gallery (Dev) |
| Production | com.example.myapp |
Gallery |
Each flavor can have different:
- API endpoints
- App icons
- App names
- Bundle identifiers
- Configuration settings
Run tests:
flutter testRun tests with coverage:
flutter test --coverageWhen you modify models or add new repositories:
flutter pub run build_runner watch --delete-conflicting-outputsCheck code quality:
flutter analyzeFormat code:
flutter format .Check for outdated packages:
flutter pub outdatedUpdate dependencies:
flutter pub upgrade-
Missing Cupertino Icons
- Ensure
cupertino_iconsis inpubspec.yaml - Run
flutter pub get
- Ensure
-
Build fails without flavor
- Always specify
--flavorand-twhen building - Use
developmentorproductionflavor
- Always specify
-
Gradle build issues
- Clean the build:
flutter clean - Rebuild:
flutter pub get && flutter build apk --flavor production -t lib/main_prod.dart
- Clean the build:
Contributions are welcome! Please feel free to submit a Pull Request.
Note: Make sure to configure your .env file and signing configurations before building release versions.