A modern, responsive Flutter application showcasing a Clean Architecture implementation with a robust set of libraries and tools. This project serves as a comprehensive base for building scalable Flutter apps, currently demonstrating a Movie Database integration.
- State Management: flutter_bloc
- Routing: go_router
- Networking: dio & retrofit
- JSON Parsing: json_serializable & json_annotation
- Data Comparison: equatable
- Image Caching: cached_network_image
- Local Storage: shared_preferences
The project strictly follows Clean Architecture principles, dividing the code into discrete, decoupled layers:
lib/
βββ core/
β βββ common/ # Shared elements like AppTheme and ThemeCubit (Light/Dark Mode)
β βββ configs/ # App-wide configurations and constants
β βββ database/ # Local storage solutions (e.g., SharedPreferences)
β βββ failure/ # Error handling and failure models
β βββ network/ # Dio client, API Constants, Retrofit ApiClients
β βββ utils/ # Helper functions and utilities
β
βββ data/
β βββ models/ # Data models (Responses, Entities, Enums) bridging JSON and UI
β βββ repositories/ # Concrete implementations for data fetching and caching
β
βββ router/ # GoRouter configuration and route definitions
β
βββ ui/ # User Interface layer (pages and shared widgets)
β βββ pages/ # Organized by Feature (e.g., home, detail, onboarding)
β β βββ detail/ # Movie detail screen, cubit, and navigator
β β βββ home/ # Home listing screen, cubit, navigator, and local widgets
β β βββ onboarding/ # First-time user experience and onboarding bloc
β β
β βββ widgets/ # Reusable, completely stateless UI components
β βββ appbars/ # Custom AppBars
β βββ buttons/ # Reusable buttons
β βββ images/ # Network image wrappers
β βββ scaffold/ # Base scaffold widgets
β
βββ main.dart # Application entry point & root BlocProviders
1. Clone the repository and install dependencies
git clone <repository-url>
cd flutter_base_project
flutter pub get2. Run Code Generation (Crucial for Retrofit / JSON Serializable)
Because this project utilizes code generation for API Clients and JSON parsing, you must run build_runner before the project can compile successfully.
# Run one time to build generated files (.g.dart)
dart run build_runner build --delete-conflicting-outputs
# OR run securely in the background checking for file changes
dart run build_runner watch --delete-conflicting-outputsYou can run the app using the standard Flutter CLI commands:
# Run on connected device or simulator
flutter run
# Run in debug mode explicitly
flutter run --debug
# Run unit tests (if any)
flutter test
# Run static analysis to catch syntax or linting errors
flutter analyze- Dynamic Theming: An interactive toggle inside the Home App Bar seamlessly switches between Light and Dark mode using a
ThemeCubit. - Code-Generated API Routes: Utilizes Retrofit to cleanly declare API routes on an interface, abstracting away complex parsing and boilerplate code.
- Component Extraction: All generic UI logic (Scaffolds, custom App Bars, Back Buttons, Network Images) are perfectly modularized into
lib/core/widgetsfor instantaneous reuse.