An open API service indexing awesome lists of open source software.

https://github.com/sakibvhossain/flutter_clean_architecture


https://github.com/sakibvhossain/flutter_clean_architecture

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# Flutter

# Clean Architecture vs Hybrid Modular Approach Folder Structure

This document provides a recommended folder structure for implementing Clean Architecture in a Flutter application. Clean Architecture helps maintain separation of concerns, making code easier to test, maintain, and scale.

## Folder Structure for Hybrid Modular Approach

```plaintext
└──T-Store/
└──lib/
├── common/
│ ├── styles
│ ├── widgets
├── controller
├── data/
│ └── models
│ ├── model
│ ├── repositories
│ ├── services
├── localization
├── screens
├── util/
│ ├── constants
│ ├── devices
│ ├── formatters
│ ├── helpers
│ └── theme
├── app.dart
└── main.dart
```
## Folder Structure for Clean Architecture
```plaintext
lib/
├── data/ # Data sources, such as API clients, local data sources
│ ├── models/
│ ├── repositories/
│ └── sources/
├── domain/ # Core business logic, entities, and use cases
│ ├── entities/
│ └── use_cases/
├── presentation/ # UI and presentation logic (e.g., blocs, controllers)
│ ├── widgets/
│ └── screens/
└── main.dart
```

# Hybrid Modular Approach vs. Clean Architecture

| **Aspect** | **Hybrid Modular Approach** | **Clean Architecture** |
|-------------------------|----------------------------------------------------------|----------------------------------------------|
| **Primary Focus** | Modular organization by feature or functional components | Separation of concerns, clear dependency rules |
| **Structure** | Feature/function-based folders (e.g., screens, data, util) | Layer-based folders (e.g., data, domain, presentation) |
| **Dependencies** | Allows flexibility, modules can reference each other freely | Inner layers can’t depend on outer layers |
| **Flexibility** | High flexibility, adaptable for various app sizes | Structured and rigid, suitable for large, scalable apps |
| **Best for** | Small to medium apps, teams looking for quick navigation | Large apps, teams with strict requirements for maintainability |
| **Pros** | - Easy navigation
- Quick to set up
- Great for smaller teams | - High maintainability
- Great for testing and scalability
- Clear layer boundaries |
| **Cons** | - Risk of tangled dependencies as the app grows
- Limited structure for larger projects | - Complex setup for small projects
- Requires strict adherence to rules and structure |