πŸš€ 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, or camelCase feature names β€” normalized consistently either way

  • Never overwrites existing generated files unless --force is 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 pubspec.yaml βœ… Done
  • 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

Libraries

flutter_feature_cli
Flutter Feature CLI.