Skip to content

saantdahal/Gallery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Gallery App

A Flutter-based gallery application with multi-flavor support for development and production environments.

πŸ“± About

A cross-platform gallery application built with Flutter, featuring clean architecture, state management with BLoC, and local caching capabilities.

πŸ› οΈ Technologies Used

Core Framework

  • Flutter SDK: ^3.5.2
  • Dart: ^3.5.2

State Management & Dependency Injection

  • 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

Networking & API

  • 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

Local Storage

  • hive: ^2.2.3 - Lightweight NoSQL database
  • hive_flutter: ^1.1.0 - Flutter integration for Hive
  • shared_preferences: ^2.3.2 - Key-value storage

UI/UX

  • 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

Navigation

  • go_router: ^14.2.8 - Declarative routing

Configuration

  • flutter_dotenv: ^6.0.0 - Environment variable management

Dev Dependencies

  • 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

πŸ“ Project Structure

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

πŸ—οΈ Architecture

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

πŸš€ Build Process

Prerequisites

  • Flutter SDK (^3.5.2 or higher)
  • Dart SDK (^3.5.2 or higher)
  • Android Studio / Xcode (for platform-specific builds)

Setup

  1. Clone the repository

    git clone <repository-url>
    cd gallery
  2. Install dependencies

    flutter pub get
  3. Generate code (for models, repositories, etc.)

    flutter pub run build_runner build --delete-conflicting-outputs
  4. Configure environment variables

    • Create a .env file in the root directory
    • Add necessary API keys and configurations

Building the App

The app uses Flutter Flavorizr for managing multiple build flavors (Development & Production).

Development Build

Android APK:

flutter build apk --release --flavor development -t lib/main_dev.dart

iOS:

flutter build ios --release --flavor development -t lib/main_dev.dart

Run on device:

flutter run --flavor development -t lib/main_dev.dart

Production Build

Android APK:

flutter build apk --release --flavor production -t lib/main_prod.dart

Android App Bundle (for Play Store):

flutter build appbundle --release --flavor production -t lib/main_prod.dart

iOS:

flutter build ios --release --flavor production -t lib/main_prod.dart

Run on device:

flutter run --flavor production -t lib/main_prod.dart

Build Outputs

  • 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

🎨 Flavors

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

πŸ§ͺ Testing

Run tests:

flutter test

Run tests with coverage:

flutter test --coverage

πŸ”§ Development

Code Generation

When you modify models or add new repositories:

flutter pub run build_runner watch --delete-conflicting-outputs

Linting

Check code quality:

flutter analyze

Format code:

flutter format .

πŸ“¦ Dependencies Update

Check for outdated packages:

flutter pub outdated

Update dependencies:

flutter pub upgrade

πŸ› Troubleshooting

Common Issues

  1. Missing Cupertino Icons

    • Ensure cupertino_icons is in pubspec.yaml
    • Run flutter pub get
  2. Build fails without flavor

    • Always specify --flavor and -t when building
    • Use development or production flavor
  3. Gradle build issues

    • Clean the build: flutter clean
    • Rebuild: flutter pub get && flutter build apk --flavor production -t lib/main_prod.dart

πŸ‘₯ Contributing

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.

About

A Flutter-based gallery application with multi-flavor support for development and production environments.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages