Flutter Clean Architecture Learning Journey | Step by Step
I'm sharing my personal journey learning Clean Architecture with Flutter. Every commit is a real step in my learning path.
- Clean Architecture layers (Presentation, Domain, Data)
- Professional resource management (Colors, Fonts, Themes, Strings, Assets...)
- MVVM Architecture for OnBoarding Screen
- Mock API with WireMock
- Dio + Retrofit setup with code generation + Pretty Dio Logger
- BaseResponse + multiple typed response models
- Extension Functions & Mapper extensions
- Login models in Domain Layer
AppServiceClientusing Retrofit + Dio- Organized Data Layer (network + response folders)
- RemoteDataSource interface + implementation
- NetworkInfo interface + implementation
- Failure class + advanced Error Handler
- Repository interface + RepositoryImpl
- BaseUsecase + LoginUsecase
- App Preferences & Language management
- Dio Factory improvements
J.mp4
1. Project setup + clean main.dart
2. Create layers folders (presentation, domain, data, app)
3. Create Application class + Singleton Pattern
4-14. Add Resource Managers (Color, Font, Style, Theme, Route, String, Asset, Constants...)
15. OnBoarding Assets & Strings
16. OnBoarding Screen (first implementation)
17. OnBoarding Screen Refactoring with MVVM
18. Add Dio + Retrofit + json_serializable packages
19. Create BaseResponse class + specific response models
20. Code generation for JSON handling (build_runner)
21. Add the API client class using the retrofit package
22. Create login models to represent the data structure of the response
23. Create extensions functions
24. Create mapper extensions
25. Start implementing the login request
26. Create the remote data source class and remote data source implementation class
27. Add the network info class and network info implementation class
28. Create repository implementation class
29. Add error handler class
30. Enhance error handling
31. Implement Dio factory class
32. Add Pretty Dio Logger
33. Add timeout & language manager
34. Add App Preferences
35. Refactor DioFactory
36. Add BaseUsecase
37. Add LoginUsecase
38. Add LoginViewModel to manage login screen state and interactions
39. enhance LoginViewModel with detailed comments and stream management
40. Implement LoginObject data class and update login view model methods
41. Update LoginViewModel to manage loginObject state and fix stream controller initialization
42. Implement LoginView with ViewModel binding and text field listeners
43. Implement form validation and UI updates based on ViewModel streams
44. register SharedPreferences in dependency injection
45. Register NetworkInfo instance in dependency injection and update LoginViewModel instantiation to use GetIt instance
46. Fix the issue of the login API
---
- β Clean Architecture Structure
- β Singleton Pattern
- β MVVM Architecture
- β Resource Management
- β Route Management with RouteGenerator
- β Mock API with WireMock
- β Dio + Retrofit + Code Generation
- β JSON Serialization (json_serializable)
- β extensions functions
- β Mapping
- β Either
- β Remote Data Source
- β Error Handler
- β UseCase
- β Broadcasting
- β Data Classes
- β Dependency Injection
lib/
βββ app/
β βββ app.dart
β βββ constants.dart
β βββ app_prefs.dart
β βββ di.dart
β βββ extensions.dart
βββ presentation/
β βββ forgotPassword/
β β βββforgot_password.dart
β βββ login/
β β βββview
β β β βββlogin_view.dart
β β βββviewModel
β β βββlogin_viewmodel.dart
β βββ main/
β β βββmain_view.dart
β βββ onBoarding/
β β βββview/
β β β βββon_boarding_view.dart
β β βββviewModel/
β β βββon_boarding_viewmodel.dart
β βββ register/
β β βββregister_view.dart
β βββ resource/
β β βββ assets_manager.dart
β β βββ color_manager.dart
β β βββ constants_manager.dart
β β βββ language_manager.dart
β β βββ font_manager.dart
β β βββ routes_manager.dart
β β βββ strings_manager.dart
β β βββ style_manager.dart
β β βββ theme_manager.dart
β β βββ values_manager.dart
β βββ splash/
β β βββ splash_view.dart
β βββ storeDetails/
β β βββ store_details_view.dart
β βββ common
β βββ freezed_data_classes.dart
β βββ freezed_data_classes.freezed.dart
βββ domain/
β βββ models/
β β βββ models.dart
β βββ repository/
β β βββ repository.dart
β βββ usecase/
β βββ base_usecase.dart
β βββ login_usecase.dart
βββ data/
βββ network/
β βββ app_api.dart
β βββ app_api.g.dart
β βββ dio_factory.dart
β βββ failure.dart
β βββ error_handler.dart
β βββ network_info.dart
β βββ requests.dart
ββ response/
β βββ response.dart
β βββ response.g.dart
βββ mapper/
β βββ mapper.dart
βββ data_source/
β βββ remote_data_source.dart
βββ repository/
βββ repository_impl.dart 
