flutter_feature_cli 1.2.0
flutter_feature_cli: ^1.2.0 copied to clipboard
A Flutter CLI for generating feature modules using Partial Clean Architecture, Clean Architecture, MVC, and MVVM templates.
π Flutter Feature CLI #
Generate Flutter feature architecture in seconds.
A lightweight CLI tool that scaffolds feature modules using popular architectural patterns such as Partial Clean Architecture, Clean Architecture, MVC, and MVVM.
β¨ Features #
-
Generate complete feature structures instantly
-
Supports multiple architecture templates:
- Partial Clean Architecture
- Clean Architecture
- MVC
- MVVM
- Custom (define your own folder/file structure via
pubspec.yaml)
-
Configurable output path via
pubspec.yaml -
Supports command-level path overrides
-
Auto-generates barrel exports (
index.dart) -
Reduces repetitive boilerplate code
-
Accepts
snake_case,kebab-case, orcamelCasefeature names β normalized consistently either way -
Never overwrites existing generated files unless
--forceis passed -
Fully tested and production-ready
π¦ Installation #
Add the package to your Flutter project:
dev_dependencies:
flutter_feature_cli: ^1.2.0
Install dependencies:
flutter pub get
βοΈ Configuration (Optional) #
Configure a default feature generation path in your project's pubspec.yaml.
flutter_feature_cli:
path: lib/src/features
If omitted, the package falls back to:
lib/features
π Create a Feature #
Generate a feature using the default template (partial_clean):
dart run flutter_feature_cli create authentication
π Templates #
Partial Clean Architecture (Default) #
dart run flutter_feature_cli create authentication
Generated structure:
authentication/
βββ data/
β βββ data_sources/
β βββ entities/
β βββ repository/
β
βββ presentation/
β βββ view_models/
β βββ widgets/
β
βββ index.dart
Clean Architecture #
dart run flutter_feature_cli create authentication \
--template clean_architecture
or
dart run flutter_feature_cli create authentication \
-t clean_architecture
Generated structure:
authentication/
βββ data/
β βββ data_sources/
β βββ models/
β βββ repositories/
β
βββ domain/
β βββ entities/
β βββ repositories/
β βββ use_cases/
β
βββ presentation/
β βββ pages/
β βββ view_models/
β βββ widgets/
β
βββ index.dart
MVC #
dart run flutter_feature_cli create authentication \
-t mvc
Generated structure:
authentication/
βββ models/
βββ controllers/
βββ views/
βββ widgets/
βββ index.dart
MVVM #
dart run flutter_feature_cli create authentication \
-t mvvm
Generated structure:
authentication/
βββ models/
βββ view_models/
βββ views/
βββ widgets/
βββ index.dart
Custom #
Define your own folder/file structure in pubspec.yaml instead of using one of
the built-in templates. Keys are folder paths relative to the feature root;
values are the explicit list of filenames to create in each folder. Use
{feature} in a filename as a placeholder for the (normalized) feature name.
flutter_feature_cli:
template: custom
custom:
data/data_sources:
- "{feature}_data_source.dart"
domain/entities:
- "{feature}_entity.dart"
presentation/views:
- "{feature}_view.dart"
- "{feature}_view_state.dart"
presentation/widgets: []
dart run flutter_feature_cli create authentication -t custom
Generated structure:
authentication/
βββ data/
β βββ data_sources/
β β βββ authentication_data_source.dart
β β βββ index.dart
β βββ index.dart
βββ domain/
β βββ entities/
β β βββ authentication_entity.dart
β β βββ index.dart
β βββ index.dart
βββ presentation/
β βββ views/
β β βββ authentication_view.dart
β β βββ authentication_view_state.dart
β β βββ index.dart
β βββ widgets/
β β βββ index.dart
β βββ index.dart
βββ index.dart
Every folder β including ones only implied by nesting, like data/ above β
gets its own barrel index.dart, matching the other templates. An empty file
list (like presentation/widgets above) still creates the folder with just a
barrel file.
Directories only, no generated files
To get a folder without any generated {feature}_*.dart stub β just the
directory itself β give it an empty list:
flutter_feature_cli:
template: custom
custom:
core/constants: []
core/utils: []
This creates core/constants/ and core/utils/ with no other files inside.
Note that a bare index.dart (empty content) is still generated in each one β
that's intentional, both to match the barrel-export convention every other
template follows and because git can't track a truly empty directory.
A folder with both files and a subfolder
A folder can own files and have a subfolder β declare the parent path with its own files, and the nested path separately:
flutter_feature_cli:
template: custom
custom:
test1:
- "{feature}_test1.dart"
test1/sub:
- "{feature}_sub.dart"
test1/
βββ sub/
β βββ {feature}_sub.dart
β βββ index.dart
βββ {feature}_test1.dart
βββ index.dart
test1/index.dart exports both: its own file first, then sub/index.dart.
π― Custom Output Path #
Override the configured path directly from the command:
dart run flutter_feature_cli create authentication \
--path lib/src/features
or
dart run flutter_feature_cli create authentication \
-p lib/src/features
You can combine both options:
dart run flutter_feature_cli create authentication \
-t clean_architecture \
-p lib/src/features
The command-line path always takes precedence over the path configured in pubspec.yaml.
π‘ Overwrite Protection #
By default, create never overwrites a file that already exists β safe to re-run on a feature you've already started editing:
dart run flutter_feature_cli create authentication
β οΈ Skipped (already exists): lib/features/authentication/data/repository/authentication_repository.dart
Pass --force (or -f) to explicitly overwrite existing generated files:
dart run flutter_feature_cli create authentication --force
π» Commands #
Generate a feature:
dart run flutter_feature_cli create <feature_name>
Generate a feature using a specific template:
dart run flutter_feature_cli create <feature_name> \
--template <template>
Generate a feature in a custom location:
dart run flutter_feature_cli create <feature_name> \
--path <path>
Overwrite existing generated files:
dart run flutter_feature_cli create <feature_name> \
--force
Available templates:
partial_clean
clean_architecture
mvc
mvvm
custom
π£ Roadmap #
Custom templates viaβ Donepubspec.yaml- Entity generation
- CRUD scaffolding
- Project setup command
- Bulk feature generation
- Architecture validation
- Feature merge utilities
π€ Contributing #
Contributions, issues, and feature requests are welcome.
π License #
MIT License
Copyright (c) 2026 Hasan Shaikh - HasneticLabs