feature_gen_cli 1.3.3
feature_gen_cli: ^1.3.3 copied to clipboard
A command-line tool for generating feature modules.
Feature Gen #
Feature Gen is a Dart CLI that scaffolds clean-architecture feature modules for Flutter projects from a JSON schema.
Quick Start #
Requirements: Dart SDK >=3.10.4, a Flutter project with a valid pubspec.yaml, and dart on your PATH.
# 1. Install
dart pub global activate feature_gen_cli
# 2. Run
feature_gen_cli <feature_name> <schema.json>
# Example: feature_gen_cli user example/user_schema.json
Schema Reference #
The schema is a single JSON file requiring three sections: config, api.methods, and response.
{
"config": { "bloc": true, "riverpod": false },
"api": {
"methods": {
"getUser": {},
"updateUser": { "body": { "name": "string", "email": "string" } },
"deleteUser": { "params": { "id": "int" } }
}
},
"response": { "id": "int", "name": "string" }
}
config: Enable exactly one state management option (blocorriverpod).api.methods: Define endpoints (camelCase). Optionally includeparams,body, orqueryto generateUseCaseand param classes.response: Define base entity/model fields. Wrap in an array for lists (e.g.,[ { "id": "int" } ]). Supports primitives ("string","int","double","bool","list","map") and nested objects.
Generated Structure #
Running the CLI produces a complete clean-architecture module in lib/features/<feature_name>/ containing:
- data/: Datasources, models, and repository implementations.
- domain/: Entities, repository interfaces, and usecases.
- presentation/: BLoC/Notifier and screens.
The CLI automatically adds missing dependencies, runs build_runner, and formats the generated code.
Troubleshooting #
- Schema validation errors: Ensure
config,api.methods, andresponseexist, and that exactly one ofconfig.blocorconfig.riverpodistrue. build_runnerfailed: Re-run it manually:dart run build_runner build -d.
Support ❤️ #
If you find this package helpful, please consider giving it a like on pub.dev and adding a ⭐ star on GitHub! Your support is greatly appreciated.
Contributing #
- Install dependencies:
dart pub get - Run tests:
dart test - Format code:
dart format .
License #
MIT