A comprehensive template for Flutter applications following Clean Architecture principles. This template provides a structured foundation with example implementations of each layer.
Note: For small projects or MVPs, implementing this full architecture might be overengineering. Consider a simpler structure if your project has minimal business logic or a small feature set.
The architecture follows Clean Architecture principles with a feature-first organization:
lib/
├── core/ # App-wide utilities, errors, and configurations
├── features/ # Feature modules following Clean Architecture
│ └── feature_name/ # e.g., auth, home, etc.
│ ├── data/ # Data layer (repositories impl, models, data sources)
│ ├── domain/ # Business logic (entities, repositories, use cases)
│ └── presentation/ # UI layer (screens, widgets)
| |__ providers
└── shared/ # Shared components across features
-
✨ Complete Clean Architecture Implementation
- Clear separation between data, domain, and presentation layers
- Example implementations for each architectural component
- Proper dependency injection setup
-
🛠️ Modern Flutter Development
- Null safety
- Route management with GoRouter
- State management with Riverpod
- Immutable programming with Freezed
-
🧰 Built-in Tools
- Error handling infrastructure
- Dependency injection setup
- Navigation service
- Route guards
- Clone this template
- Run
flutter pub get - Run
flutter pub run build_runner buildto generate code - Start implementing your features following the auth feature example
- Create a new directory under
lib/features/ - Follow the layer structure:
domain/for business logicdata/for data handlingpresentation/for UI
-
Domain Layer
- Define entities
- Create repository interfaces
- Implement use cases
-
Data Layer
- Create data models (DTOs)
- Implement repositories
- Set up data sources
-
Presentation Layer
- Create state management (Riverpod)
- Build UI components
- Handle navigation
The auth feature demonstrates:
- Clean Architecture principles
- Error handling
- State management
- Navigation
- Dependency injection
The template includes examples of:
- Unit tests for use cases
- Repository tests
- Widget tests
- Integration tests
Pre-configured with best-practice packages:
flutter_riverpodfor state managementfreezedfor immutable classesgo_routerfor navigationdartzfor functional programmingdiofor networking
Contributions are welcome.