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.
Created with ❤️ for scalable Flutter development.
