A comprehensive Flutter project demonstrating Clean Architecture principles with Cubit state management, featuring a complete authentication flow.
This project follows Clean Architecture principles with a clear separation of concerns:
lib/ ├── app/ # Application layer │ ├── app.dart # Main app configuration │ ├── di/ # Dependency injection │ ├── router/ # Navigation and routing │ └── config/ # Environment and build configuration ├── core/ # Core functionality │ ├── error/ # Error handling and failures │ ├── network/ # HTTP client and interceptors │ ├── storage/ # Local storage interfaces │ ├── utils/ # Utility functions and validators │ └── constants/ # App constants and keys ├── features/ # Feature modules │ ├── auth/ # Authentication feature │ │ ├── domain/ # Business logic and entities │ │ ├── data/ # Data sources and repositories │ │ └── presentation/ # UI and state management │ └── home/ # Home feature └── shared/ # Shared components ├── widgets/ # Reusable UI components ├── theme/ # App theming └── localization/ # Internationalization- Clean Architecture: Clear separation of concerns with domain, data, and presentation layers
- State Management: Flutter Bloc (Cubit) for predictable state management
- Dependency Injection: GetIt for service locator pattern
- HTTP Client: Dio with custom interceptors for authentication and logging
- Local Storage: Secure storage for tokens and SharedPreferences for user data
- Routing: GoRouter for declarative routing with guards
- Error Handling: Comprehensive error handling with domain-specific failures
- Validation: Form validation utilities
- Theming: Material 3 design with light/dark theme support
- Splash Screen: Checks authentication status on app start
- Login/Register: User authentication with form validation
- Token Management: Automatic token refresh and secure storage
- Protected Routes: Authentication-based navigation
- Profile Management: User profile viewing and editing
flutter_bloc: State managementdio: HTTP clientget_it: Dependency injectiongo_router: Navigationequatable: Value equalityjson_annotation: JSON serialization
shared_preferences: Local key-value storageflutter_secure_storage: Secure token storage
build_runner: Code generationinjectable_generator: DI code generationjson_serializable: JSON code generation
The app automatically detects build types and enables appropriate features:
- Debug: Full logging, debug features
- Profile: Performance monitoring, limited logging
- Release: Analytics, crash reporting, minimal logging
- Entities: Core business objects (User, AuthTokens)
- Repositories: Abstract interfaces for data operations
- Use Cases: Business logic implementation
- Models: Data transfer objects with JSON serialization
- Data Sources: Remote (API) and local (storage) data access
- Repository Implementations: Concrete implementations of domain repositories
- Pages: Full-screen UI components
- Widgets: Reusable UI components
- Cubits: State management for UI logic
- States: Immutable state representations
- Access tokens with automatic refresh
- Secure storage using flutter_secure_storage
- Interceptor-based token injection
- Domain-specific failure types
- Automatic error mapping from exceptions
- User-friendly error messages
- Authentication state management with Cubit
- Loading, success, error, and authenticated states
- Automatic navigation based on auth state
This project is licensed under the MIT License - see the LICENSE file for details.