flutter_architecture_generator 1.1.1
flutter_architecture_generator: ^1.1.1 copied to clipboard
A CLI tool to scaffold professional Flutter projects with Clean, MVVM, BLoC, GetX, or Provider architecture plus DI, routing, and tests.
๐๏ธ Flutter Architecture Generator #
A powerful, transactional CLI tool to instantly scaffold and maintain professional Flutter applications with your choice of architecture โ Clean Architecture, MVVM, BLoC, GetX, or Provider.
Stop wasting hours on boilerplate. Generate a complete, scalable project architecture in seconds โ with a transactional engine that lets you preview every change before it hits your disk.
โจ Why This Tool? #
| Feature | |
|---|---|
| ๐ | Zero to Production โ Generates a complete architecture with DI, Networking, Routing, and Material 3 Theming in seconds |
| ๐ก๏ธ | Transactional Safety โ New Plan -> Confirm -> Execute engine. Review a tree-diff of all changes before they are applied. |
| โช | Undo / Rollback โ One command to revert any destructive generation or rename operation. |
| ๐งฑ | 5 Architectures โ Clean Architecture, MVVM, BLoC, GetX, and Provider โ each with idiomatic directory structures |
| ๐ง | Context-Aware โ Remembers your project config so subsequent commands "just work" |
| โก | Auto-Wiring โ New features auto-register in your DI container and router โ no manual wiring |
| ๐ฆ | Mono-repo Support โ Native --output support for generating features into specific packages. |
| ๐จ | Modular Templates โ Drop .template files into .flutter_arch_gen/templates/ to override defaults project-wide. |
| ๐งช | Test Ready โ Generates repository tests with mock data sources for every feature |
| ๐ | Secure by Default โ .gitignore auto-generated to protect .env secrets |
๐ Table of Contents #
- Supported Features
- Installation
- Quick Start
- Commands Reference
- Maintenance & Management
- Advanced Features
- Generated Structure
- FAQ
- Contributing
- License
๐ฏ Supported Features #
Architectures #
| Architecture | Generated Structure | Key Components |
|---|---|---|
| Clean Architecture | domain/ โ data/ โ presentation/ |
Entity, Repository Interface, UseCase, DataSource, Repo Impl, BLoC/Provider |
| MVVM | models/ โ services/ โ view_models/ โ views/ |
Model, Service, ViewModel (ChangeNotifier), View |
| BLoC Architecture | models/ โ repositories/ โ bloc/ โ pages/ |
Model, Repository, Bloc + Event + State, Page |
| GetX Architecture | models/ โ controllers/ โ bindings/ โ views/ |
Model, Controller (GetxController), Binding, View |
| Provider / Simple | models/ โ providers/ โ pages/ |
Model, Provider (ChangeNotifier), Page |
State Management #
| Option | Generated Code |
|---|---|
| BLoC | Bloc + Event + State files with Equatable, part directives |
| Riverpod | FutureProvider with proper camelCase naming |
| Provider | ChangeNotifier with loading state pattern |
| GetX | GetxController with .obs reactive variables |
Routing #
| Option | Generated Code |
|---|---|
| GoRouter | GoRouter config with GoRoute entries, auto-registration of new pages |
| AutoRoute | @AutoRouterConfig with @RoutePage() annotations, auto-registration |
| Navigator | onGenerateRoute with named route constants and 404 fallback |
๐ Installation #
Global Activation #
dart pub global activate flutter_architecture_generator
โก Quick Start #
1. Create a Flutter project #
flutter create my_awesome_app
cd my_awesome_app
2. Initialize the architecture #
flutter_arch_gen init
3. Review the Plan #
The transactional engine will show you exactly what will happen:
๐๏ธ Planned Changes:
--------------------------------------------------
[+] CREATE lib/main.dart
[+] CREATE lib/app.dart
[+] CREATE lib/core/network/api_client.dart
[M] MODIFY pubspec.yaml (added 12 dependencies)
? Do you want to apply these changes? (y/N)
4. Install dependencies & generate code #
flutter pub get
dart run build_runner build --delete-conflicting-outputs
๐ Commands Reference #
flutter_arch_gen init #
Initializes the complete project architecture with interactive prompts and a transactional plan preview.
Flags:
-a, --arch: Architecture pattern (clean,mvvm, etc.)-s, --state: State management (bloc,riverpod, etc.)-r, --routing: Routing strategy (goRouter,autoRoute, etc.)-n, --dry-run: Preview changes without applying them.-c, --config: Specify a profile name (e.g.,-c dev).-o, --output: Custom output directory for monorepos.
flutter_arch_gen feature <name> #
Generates a complete feature module (Domain, Data, Presentation) with auto-wiring.
Flags:
-n, --dry-run: Preview feature files.-o, --output: Target a specific directory.-c, --config: Use a configuration profile.-f, --force: Overwrite existing feature files.
flutter_arch_gen model <name> #
Generates a Freezed model with JSON serialization. Supports standalone or feature-bound generation.
flutter_arch_gen api <url> #
New in v1.1.1! Generates Model, Repository, and Service from an endpoint URL or OpenAPI spec.
flutter_arch_gen screen <name> #
New in v1.1.1! Generates a complex screen (List, Form, Detail) with pre-wired state management.
flutter_arch_gen bloc <name> #
Generates a standalone BLoC or Cubit (--cubit flag supported).
๐ ๏ธ Maintenance & Management #
| Command | Description |
|---|---|
update |
Transactionally update your project core files and architecture logic. |
undo |
Revert the last successful command using the project's history log. |
migrate |
Switch state management or architecture mid-project. |
rename |
Rename a feature across directories, classes, DI, and routes. |
delete |
Transitionally delete a feature and un-register its bindings. |
list |
List all features and current project configuration. |
doctor |
Diagnose project health and confirm generator compatibility. |
๐ก๏ธ Advanced Features #
1. Transactional Execution Engine #
Every command that modifies more than one file runs through our transactional engine. It generates a Plan, displays a Diff, and waits for your Confirmation before touching any files.
2. Undo/Rollback System #
Made a mistake? flutter_arch_gen undo restores the state of your project before the last command. We maintain a .flutter_arch_gen_history.json to keep your project safe.
3. Modular Template System #
You can now override default templates by dropping .template files into a .flutter_arch_gen/templates/ directory in your project root. The generator will prioritize your custom templates over the built-in ones.
๐ Generated Structure #
lib/
โโโ main.dart # App entry point
โโโ core/ # Shared core logic (network, theme, errors)
โโโ di/ # GetIt Dependency Injection DI setup
โโโ features/ # Feature-first modules
โโโ routes/ # Routing configuration
โโโ .flutter_arch_gen.json # Persisted project config
โ FAQ #
Q: Can I use this on an existing project? #
A: Yes! Run flutter_arch_gen init. Our transactional engine will show you exactly what will be added or modified before you confirm.
Q: Does it support Cubit? #
A: Yes! Use flutter_arch_gen bloc <name> --cubit to generate a Cubit instead of a BLoC.
Q: How do I handle monorepos? #
A: Use the --output (or -o) flag to target specific packages within your monorepo.
๐ค Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License #
This project is licensed under the MIT License.
Made with โค๏ธ for the Flutter community