This project is a hands-on implementation of Clean Architecture principles in Flutter. It is designed for learning purposes, demonstrating how to build a scalable, testable, and maintainable mobile application using modern industrial standards.
The application consumes a remote E-commerce Dashboard API and displays it using a modular, feature-based structure. It emphasizes the separation of concerns, ensuring that business logic is isolated from UI and external data sources.
Clean Architecture divides the application into distinct layers to manage complexity and dependencies.
Located in lib/features/[feature_name]/presentation/.
This layer is responsible for the UI and state management.
- Bloc/Providers: Handles business logic and UI state transitions.
- Pages/Widgets: Pure UI components that listen to state changes.
Located in lib/features/[feature_name]/data/.
This layer handles the "How" of data retrieval.
- Models: Data transfer objects (DTOs) that represent the JSON structure of an API. In this project, we utilize a Unified Model approach where Entities and Models coexist in a single class to reduce boilerplate while maintaining structure.
- Data Sources: Low-level implementation of network calls (Retrofit/Dio) or local storage.
- Repositories (Implementation): Coordinates data from multiple sources and returns them to the Presentation layer.
While strict Clean Architecture requires significant boilerplate (manual mapping between Models and Entities, mandatory UseCases for every action), this project adopts a Pragmatic Clean Architecture approach to accelerate development:
- Unified Schema: Models use JSON annotations and reside in the data layer to avoid redundant mapping extensions.
- Simplified Flow: UseCases are omitted; the Bloc interacts directly with the Repository.
- State Management: flutter_bloc
- Networking: Retrofit & Dio
- Dependency Injection: Injectable & GetIt
- Data Handling: Freezed & JSON Serializable
- Functional Programming: fpdart (Either for error handling)
To run this project:
- Ensure you have the Flutter SDK installed.
- Clone the repository.
- Run
flutter pub get. - Run
dart run build_runner build -dto generate necessary code for DI and JSON serialization. - Execute
flutter run.
This project serves as a template for those looking to understand how to bridge the gap between architectural theory and real-world development deadlines.