A powerful Bash script that generates complete Flutter features following Clean Architecture principles with support for multiple state management solutions and testing.
- ποΈ Clean Architecture: Generates proper Data β Domain β Presentation layer structure
- π§ Multiple State Management: Support for Riverpod, Bloc, and Cubit
- βοΈ Freezed Support: Unified immutable models and state classes
- π§ͺ Test Generation: Complete test suite generation with proper mocking
- π Smart Naming: Automatic conversion from natural language to proper Dart conventions
- β‘ Zero Configuration: Works out of the box with sensible defaults
git clone https://github.com/jamal-and/flutter_feature_generator.git
cd flutter_feature_generator
./install.sh
source ~/.zshrc # or source ~/.bashrc# Generate a basic feature
cf "User Profile"
# Generate with Riverpod + Freezed + tests
cf "Shopping Cart" --riverpod --freezed --test
# Generate with Bloc + Equatable models + tests
cf "Product Details" --bloc --equatable --testcf <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
# User feed with advanced state management
cf "Social Feed" --riverpod --freezed --test
# Profile management
cf "User Profile" --bloc --test
# Chat system
cf "Chat" --cubit --freezedclass UserProfileController extends Notifier<UserProfileState> {
@override
UserProfileState build() => const UserProfileState();
Future<void> loadData() async {
state = state.copyWith(isLoading: true);
// Implementation...
}
}class UserProfileBloc extends Bloc<UserProfileEvent, UserProfileState> {
UserProfileBloc() : super(const UserProfileState.initial()) {
on<_FetchData>((event, emit) async {
emit(const UserProfileState.loading());
// Implementation...
});
}
}class UserProfileCubit extends Cubit<UserProfileState> {
UserProfileCubit() : super(const UserProfileState.initial());
Future<void> loadData() async {
emit(const UserProfileState.loading());
// Implementation...
}
}When 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 suggests 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
This project is licensed under the MIT License - see the LICENSE file for details.
- 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!