A ready-to-use project structure for scalable and testable Flutter apps using Clean Architecture principles and Test-Driven Development (TDD).
- Architecture: Clean Architecture (Domain, Data, Presentation)
- State Management: BLoC
- Dependency Injection: get_it
- Networking: Dio
- Code Generation: Freezed, JsonSerializable
- Testing: Unit, Bloc, and Widget Tests
lib/
βββ core/
β βββ di/
β βββ error/
β βββ usecases/
βββ features/
β βββ auth/
β βββ data/
β βββ domain/
β βββ presentation/
βββ main.dart
.
test/
βββ features/
. βββ auth/
. βββ data/
. βββ domain/
. βββ presentation/
- Model Layer:
UserModelJSON serialization/deserialization, equality, and factory tests - Repository Layer:
AuthRepositoryImplunit tests for both success and failure cases - Use Cases:
Loginuse case tested for correct interaction with repository and error handling - BLoC: Comprehensive tests for all AuthBloc states:
- Initial, Loading, Success, Failure transitions
- Mocked use case integration
- UI Tests:
LoginPagewidget tests:- Input validations
- Form submission dispatch
- Success and failure snackbar behaviors
- Make the script executable:
chmod +x script.sh
- Create your app:
./script.sh <your_app_name>
- Run tests when prompted or manually:
flutter test
Note: This boilerplate is designed for long-term scalability, maintainability, and high test coverage from day one.
Platform Note: This script runs best on macOS/Linux. Use Git Bash or WSL on Windows.
# βοΈ Flutter Clean Architecture Project Generator (Windows version)
Created with β€οΈ for scalable Flutter development.
- Install Git for Windows
- Open Git Bash in the folder containing
script.sh - Run:
bash script.sh <your_app_name>
