arch_wizard 1.0.4
arch_wizard: ^1.0.4 copied to clipboard
A powerful CLI tool to scaffold Flutter clean architecture features...
Arch Wizard π§ββοΈβ¨ #
Effortless Flutter Feature Scaffolding with Clean Architecture #
Stop writing boilerplate and start building features. Arch Wizard is a powerful, flexible command-line tool designed to automate the creation of entire feature modules for Flutter apps, all perfectly structured according to Clean Architecture principles. Save time, reduce repetitive code, and maintain consistency across your projects and teams.
β¨ Key Features #
- Automated Scaffolding: Generate a complete feature with domain, data, and presentation layers using a single command.
- Clean Architecture Enforcement: Keep your code modular, testable, and maintainable.
- Supports Multiple State Management Solutions:
BLoC
,Riverpod
,GetX
, andProvider
. - Automatic Dependency Injection Registration: Seamlessly updates your
get_it
service locator setup. - Production-Ready Templates: Includes robust error handling and architecture best practices.
- Automatic Global Failure Classes: When creating a feature, Arch Wizard automatically creates the global
Failure
classes andFailureMapper
files (if they don't exist) in your projectβslib/core/error/
directory.
π Installation #
Add arch_wizard
to the flutter project:
flutter pub add arch_wizard
Install Arch Wizard globally via Dart's pub tool to use it anywhere:
dart pub global activate arch_wizard
Ensure your system's PATH includes pub global executables so the arch_wizard
command is recognized.
π Usage #
Step 1: Run the Feature Creation Command #
From the root of your Flutter project, run the main command:
arch_wizard create_feature --name <feature_name> --state <state_management>
- Replace
<feature_name>
with your desired feature name (e.g.,login
). - Choose your preferred state management from
bloc
,riverpod
,getx
, orprovider
.
Step 2: Example Commands #
# Generate a Login feature using BLoC
arch_wizard create_feature --name login --state bloc
# Generate a Product feature using Riverpod
arch_wizard create_feature --name product --state riverpod
# Generate a Profile feature using GetX
arch_wizard create_feature --name profile --state getx
# Generate a Cart feature using Provider
arch_wizard create_feature --name cart --state provider
π Generated File Structure #
Arch Wizard generates a complete and logically separated module for your feature. Hereβs a look at the architecture.
General Structure #
All generated features follow this core layout, ensuring consistency and separation of concerns.
<your_project_name>/
βββ lib/
βββ core/
β βββ error/
β βββ failure.dart # (Auto-generated) Base Failure classes.
β βββ failure_mapper.dart # (Auto-generated) Maps exceptions to Failures.
β
βββ features/
β βββ <feature_name>/
β βββ data/
β β βββ datasources/
β β β βββ <feature_name>_remote_datasource.dart
β β βββ models/
β β β βββ <feature_name>_model.dart
β β βββ repositories/
β β βββ <feature_name>_repository_impl.dart
β βββ domain/
β β βββ entities/
β β β βββ <feature_name>_entity.dart
β β βββ repositories/
β β β βββ <feature_name>_repository.dart
β β βββ usecases/
β β βββ <feature_name>_usecase.dart
β βββ presentation/
β # This layer's content changes based on the chosen state management.
β # See examples below.
β
βββ injection_container.dart # (MODIFIED) Automatically updated with new dependencies.
State Management Variations #
The presentation
layer is tailored to your chosen state management solution. Here are the specific structures generated inside lib/features/<feature_name>/presentation/
.
π§± BLoC (--state bloc
)
presentation/
βββ bloc/
β βββ <feature_name>_bloc.dart
β βββ <feature_name>_event.dart
β βββ <feature_name>_state.dart
βββ pages/
β βββ <feature_name>_page.dart
βββ widgets/
βββ <feature_name>_widget.dart
π Riverpod (--state riverpod
)
presentation/
βββ notifiers/
β βββ <feature_name>_state_notifier.dart
βββ pages/
β βββ <feature_name>_page.dart
βββ providers/
β βββ <feature_name>_providers.dart
βββ widgets/
βββ <feature_name>_widget.dart
π GetX (--state getx
)
presentation/
βββ bindings/
β βββ <feature_name>_binding.dart
βββ controllers/
β βββ <feature_name>_controller.dart
βββ pages/
β βββ <feature_name>_page.dart
βββ widgets/
βββ <feature_name>_widget.dart
ChangeNotifier For Provider (--state provider
)
presentation/
βββ pages/
β βββ <feature_name>_page.dart
βββ providers/
β βββ <feature_name>_provider.dart
βββ widgets/
βββ <feature_name>_widget.dart
βοΈ Command Options #
Option | Alias | Description | Allowed Values | Default |
---|---|---|---|---|
--name |
-n |
Name of the feature to create | Any valid string (e.g., login ) |
β |
--state |
-s |
State management approach | bloc , riverpod , getx , provider |
bloc |
π‘ Tips for Customization #
- Generated templates include clear comments and
TODO
s to guide you in customizing API calls, UI, and business logic. - Supports multi-layer clean architecture, so you can replace or extend any layer independently.
- Easily integrate with your existing codebase by following the generated file and folder structure.
π€ Contributing #
Contributions are welcome! If you have suggestions for improvements or new features, feel free to open an issue or submit a pull request.
π License #
Arch Wizard is open-source software licensed under the MIT License. See the LICENSE
file for details.
Happy coding! π #
Build clean, scalable Flutter apps faster with Arch Wizard.