A simple Dart CLI tool to instantly scaffold Clean Architecture feature folders in your Flutter project.
Save time, stay consistent, and generate complete feature modules with one command!
Install it globally via pub.dev:
dart pub global activate flutter_feature_genMake sure Dart's pub global bin is in your PATH (usually ~/.pub-cache/bin).
If not, add this to your .bashrc / .zshrc:
export PATH="$HOME/.pub-cache/bin:$PATH"flutter_feature_gen <feature_name> [state_management] [options]--riverpod- Riverpod Notifier--bloc- Bloc pattern (Event + State + Bloc)--cubit- Cubit pattern (simplified Bloc)
--freezed- Use Freezed for immutable models and state classes--test- Generate comprehensive test files
lib/features/your_feature/
├── data/
│ ├── datasources/
│ │ ├── your_feature_remote_datasource.dart
│ │ ├── your_feature_remote_datasource_impl.dart
│ │ ├── your_feature_local_datasource.dart
│ │ └── your_feature_local_datasource_impl.dart
│ ├── models/
│ │ └── your_feature_model.dart
│ └── repositories/
│ └── your_feature_repository_impl.dart
├── domain/
│ ├── entities/
│ │ └── your_feature_entity.dart
│ ├── repositories/
│ │ └── your_feature_repository.dart
│ └── usecases/
│ └── get_your_feature_usecase.dart
└── presentation/
├── controller/
│ └── [state_management_files]
├── screens/
│ └── your_feature_screen.dart
└── widgets/
└── your_feature_card.dart
Each folder includes boilerplate Dart files (models, repositories, use cases, screens, widgets, etc.).
- Converts
meal-plan,meal_plan, orMeal Plan→MealPlanModel,MealPlanRepository, etc. - Folder:
lib/features/meal_plan/ - Class Names:
MealPlanScreen,MealPlanModel, etc.
# User feed with advanced state management
flutter_feature_gen "Social Feed" --riverpod --freezed --test
# Profile management
flutter_feature_gen "User Profile" --bloc --test
# Chat system
flutter_feature_gen "Chat" --cubit --freezedCreates:
lib/features/chat/chat_model.dartchat_repository.dartchat_screen.dart- And more...
Add this to your .zshrc or .bashrc:
alias cf='flutter_feature_gen'Then use:
cf workout_trackerWhen using --test, the script generates:
- Unit Tests: For all business logic components
- Widget Tests: For UI components
- Integration Tests: For complete workflows
- Mock Classes: Using Mocktail for clean testing
Example test structure:
test/features/your_feature/
├── data/
│ ├── datasources/
│ ├── models/
│ └── repositories/
├── domain/
│ ├── entities/
│ ├── repositories/
│ └── usecases/
└── presentation/
├── controller/
├── screens/
└── widgets/
The script automatically adds the required dependencies based on your choices:
dependencies:
dio: ^5.3.2
flutter_riverpod: # if --riverpod
flutter_bloc: # if --bloc or --cubit
freezed_annotation: # if --freezed
json_annotation: dev_dependencies:
flutter_test:
sdk: flutter
mocktail:
bloc_test: # if --bloc or --cubit
build_runner: # if using Freezed
freezed: # if --freezed
json_serializable: The script intelligently handles various naming conventions:
cf "user profile" # → user_profile (snake_case files)
cf "UserProfile" # → user_profile (snake_case files)
cf "User-Profile" # → user_profile (snake_case files)
cf "User Profile API" # → user_profile_api (handles multiple words)For Freezed-based features, don't forget to run:
dart dart run build_runner build --delete-conflicting-outputs
The script generates production-ready code with:
- ✅ Proper error handling
- ✅ Type safety
- ✅ Null safety compliance
- ✅ Clean separation of concerns
- ✅ Testable architecture
- ✅ Industry best practices
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License © 2025 Jamal Sfenjeh
- Inspired by Clean Architecture principles by Robert C. Martin
- Flutter community best practices
- Modern state management patterns
Found a bug or have a feature request? Please open an issue.
Made with ❤️ for the Flutter community
⭐ Star this repo if it helped you!