flutter_architecture_cli 1.0.1 copy "flutter_architecture_cli: ^1.0.1" to clipboard
flutter_architecture_cli: ^1.0.1 copied to clipboard

A command-line tool to generate a production-ready clean architecture in Flutter using RxDart and Provider.

Flutter Architecture CLI #

pub package License: MIT Platform Support

A production-grade command-line tool designed to generate and scale clean architecture codebases in Flutter. It eliminates repetitive setup, enforcing a modular, highly scalable, and team-friendly project structure powered by RxDart streams and Provider.


Table of Contents #


Features #

  • Zero-Configuration Architecture Setup: Instant scaffolding covering storage, networking, localizations, utility helpers, and dependency injection.
  • Stream-Based State Management: Seamless state handling inside Blocs using RxDart's BehaviorSubject and CompositeSubscription.
  • Centralized Networking: Custom ApiClient powered by Dio with automatic logging, secure token handling, and robust exception-handling interceptors.
  • Unified UI State: Standardized BaseUiState class for mapping screen loading, success, and error states.
  • Common Widget Toolkit: Reusable components such as AppText, AppImage, AppTextField, AppButton, AppLoader, AppShimmer, and AppNetworkStatusWidget.
  • JSON-Based Localization: Fully configured translations with convenient context translation extensions (context.tr(...)).

Folder Structure #

Generating a project produces this structured, clean tree:

lib/
├── common/
│   ├── extensions/       # BuildContext, String, DateTime and Widget extensions
│   ├── helpers/          # Bottom sheets, dialogs, snackbars, and navigation helpers
│   └── widgets/          # Highly reusable common widgets (AppButton, AppLoader, etc.)
├── core/
│   ├── base/             # BaseBloc, BaseMapper, and BaseUiState
│   ├── constants/        # Api endpoints, dimensions, route names, regex, etc.
│   ├── localization/     # Localization service and JSON delegates
│   ├── network/          # ApiClient configurations, interceptors, and custom exceptions
│   ├── storage/          # SharedPreferences manager and secure storage
│   ├── theme/            # AppThemeData, custom borders, shadows, and text styles
│   └── utils/            # Validators, connectivity helpers, pickers, and logger
├── src/
│   └── users/            # Pre-generated dummy feature showcasing architecture
│       ├── bloc/         # RxDart user_bloc.dart
│       ├── data_source/  # user_datasource.dart
│       ├── mapper/       # user_mapper.dart (BaseMapper implementation)
│       ├── model/
│       │   ├── request/  # Empty folder placeholder for request parameters
│       │   ├── response/ # user_response.dart (Raw network DTO)
│       │   └── ui_entity/# user_ui_entity.dart (UI data model)
│       ├── presentation/
│       │   ├── view/     # user_screen.dart
│       │   └── widget/   # Feature-specific sub-widgets
│       ├── repository/   # user_repository.dart
│       └── state/        # user_state.dart & user_provider.dart
└── main.dart             # Application root bootstrapper

Installation #

Activate the package globally to make the command available system-wide:

dart pub global activate flutter_architecture_cli

Usage Guide #

1. Creating a New Application #

Generate a fully bootstrapped Flutter project matching the architecture style:

flutter_architecture_cli create <app_name>

Example:

flutter_architecture_cli create my_awesome_app

2. Creating a Feature #

Instantly scaffold a complete feature directory with its nested folders (bloc, data_source, mapper, model/request, model/response, model/ui_entity, presentation/view, presentation/widget, repository, state):

flutter_architecture_cli create_feature <feature_name>

Example:

flutter_architecture_cli create_feature products

3. Creating a Screen #

Add a new screen to the presentation layer of a specific feature:

flutter_architecture_cli create_screen <screen_name> -f <feature_name>

Example:

flutter_architecture_cli create_screen product_detail -f products

4. Creating Models #

Generate model response DTOs and matching UI Entity classes:

flutter_architecture_cli create_model <model_name> -f <feature_name>

Example:

flutter_architecture_cli create_model category -f products

5. Creating Data Sources #

Generate a data source class in the specified feature:

flutter_architecture_cli create_datasource <name> -f <feature_name>

6. Creating Repositories #

Generate a repository class to bridge your data source and domain layer:

flutter_architecture_cli create_repository <name> -f <feature_name>

Architecture Flow #

The generated structure focuses on a single directional data flow:

  1. DataSource: Fetches raw JSON data using ApiClient and parses it into a Response DTO (model/response/).
  2. Mapper: Inherits from BaseMapper to transform the Response DTO into a clean UI Entity (model/ui_entity/).
  3. Repository: Requests data from DataSource and runs the mapped results up to the Bloc layer.
  4. Bloc: Standardizes UI state management by converting repository streams into BaseUiState (Loading -> Completed/Error) emitted via BehaviorSubject.
  5. Presentation (View): Listens to the Bloc subjects using StreamBuilder and renders loading, success, or error screens automatically.

Contributing #

Contributions are welcome! If you want to suggest an improvement, report a bug, or add new command options:

  1. Fork the repository: https://github.com/Dharti1623/flutter_architecture_cli
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request detailing your changes.

Support & Donations #

If this CLI generator saved you time and made your Flutter development easier, consider supporting the project:

9
likes
0
points
222
downloads

Publisher

verified publisherdhartichauhan.blogspot.com

Weekly Downloads

A command-line tool to generate a production-ready clean architecture in Flutter using RxDart and Provider.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

args, io, path

More

Packages that depend on flutter_architecture_cli