flutter_architecture_cli 1.0.5
flutter_architecture_cli: ^1.0.5 copied to clipboard
A command-line tool to generate production-ready clean architecture in Flutter using flutter_bloc, GetX, or RxDart & Provider.
Flutter Architecture CLI #
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 with your choice of state management: RxDart + Provider (Stream-driven), flutter_bloc (Event & State-driven), or GetX (Reactive Controller & Bindings).
Tip
Read the complete setup and detailed architectural guide on Medium: Stop Writing Boilerplate: Scaffold a Flutter Clean Architecture App in 60 Seconds!
Table of Contents #
- Installation & Setup
- FVM (Flutter Version Management) Support
- Features
- Folder Structure
- State Management Isolation
- Usage Guide
- 1. create — Scaffold a New App
- 2. create_feature — Generate Feature Layer
- 3. create_screen — Add Presentation Screen
- 4. create_model — Generate UI Entity & Response DTO
- 5. create_datasource — Generate API Data Source
- 6. create_repository — Generate Repository
- 7. create_service — Generate Core Singleton Service
- 8. change_bundle_id — Rename Bundle ID / Package Name
- Architecture Flow
- Form Validation Helper
- Roadmap / Future Goals
- Contributing
- Support & Donations
Installation & Setup #
You can use flutter_architecture_cli in two convenient ways:
Method 1: Project Dev Dependency (Recommended) #
This method ensures everyone on your team has access to the CLI with matching versions, without requiring machine-wide global installs.
A. New Projects Created via the CLI
When you scaffold an application using flutter_architecture_cli create <app_name>, the tool automatically adds flutter_architecture_cli to your dev_dependencies inside pubspec.yaml!
You can immediately navigate into your project folder and run commands:
# Standard Flutter
dart run flutter_architecture_cli <command>
# Or with FVM
fvm dart run flutter_architecture_cli <command>
B. Adding to Existing Projects
To add the CLI to an existing Flutter codebase:
# Standard Flutter
flutter pub add --dev flutter_architecture_cli
# Or with FVM
fvm flutter pub add --dev flutter_architecture_cli
Once installed, run any command from your project root:
dart run flutter_architecture_cli <command>
# (or with FVM: fvm dart run flutter_architecture_cli <command>)
Method 2: Global Installation #
If you prefer having the CLI globally accessible from any terminal window without prefixing dart run:
Standard Flutter:
dart pub global activate flutter_architecture_cli
With FVM:
fvm dart pub global activate flutter_architecture_cli
Note: Make sure your global pub cache bin directory is in your system's
PATH:
- macOS/Linux:
export PATH="$PATH":"$HOME/.pub-cache/bin"- Windows:
%USERPROFILE%\AppData\Local\Pub\Cache\bin
Once activated globally, execute commands directly:
flutter_architecture_cli <command>
Method 3: Local Path Installation (Development) #
If you are developing the CLI locally, testing new features, or working on unreleased versions without waiting for a pub.dev release:
# Link your local working copy globally:
dart pub global activate --source path /path/to/flutter_architecture_cli
# Or with FVM:
fvm dart pub global activate --source path /path/to/flutter_architecture_cli
Once activated, flutter_architecture_cli will execute your local source code directly from any terminal window across your system.
FVM (Flutter Version Management) Support #
flutter_architecture_cli includes complete, first-class support for FVM out of the box.
Why FVM Support Was Added (v1.0.4) #
Previously, developers who set up FVM using shell aliases (e.g., alias flutter="fvm flutter") encountered command not found (exit code 127) because non-interactive subshells do not source .zshrc / .bashrc aliases. In v1.0.4+, the CLI natively detects FVM binaries and routes all Flutter and Dart operations through fvm flutter and fvm dart seamlessly.
How FVM Works in this CLI #
- Smart Auto-Detection:
- Missing Global Flutter: If
flutteris missing from your systemPATHbutfvmis installed, the CLI automatically detects FVM and switches tofvm flutterwithout requiring any manual flags. - Workspace Detection: If an
.fvm/directory or.fvmrcfile exists in your workspace, FVM is automatically preferred for all operations.
- Missing Global Flutter: If
- Explicit Flags (
--fvmand--fvm-version):- Pass
--fvmto explicitly force FVM execution:flutter_architecture_cli create my_app --fvm - Optionally pin a specific Flutter version during creation:
flutter_architecture_cli create my_app --fvm --fvm-version 3.22.0
- Pass
- Automated IDE & Git Configuration:
- Automatically adds
.fvm/flutter_sdkto the generated.gitignore. - Automatically creates
.vscode/settings.jsonwith"dart.flutterSdkPath": ".fvm/flutter_sdk"so VS Code immediately binds the correct Flutter SDK.
- Automatically adds
- All Subcommands Support FVM:
- When running feature, screen, or model generation inside an FVM project, code formatting automatically uses
fvm dart format.
- When running feature, screen, or model generation inside an FVM project, code formatting automatically uses
Quick FVM Cheat Sheet #
| Task | Standard Flutter | With FVM |
|---|---|---|
| Global Install | dart pub global activate flutter_architecture_cli |
fvm dart pub global activate flutter_architecture_cli |
| Add as Dev Dependency | flutter pub add --dev flutter_architecture_cli |
fvm flutter pub add --dev flutter_architecture_cli |
| Create Project (Default / Interactive) | flutter_architecture_cli create my_app |
flutter_architecture_cli create my_app --fvm |
| Create with BLoC | flutter_architecture_cli create my_app --bloc |
flutter_architecture_cli create my_app --bloc --fvm |
| Create with GetX | flutter_architecture_cli create my_app --getx |
flutter_architecture_cli create my_app --getx --fvm |
| Create with Pinned SDK | N/A | flutter_architecture_cli create my_app --fvm --fvm-version 3.22.0 |
| Create Feature | dart run flutter_architecture_cli create_feature auth |
fvm dart run flutter_architecture_cli create_feature auth |
| Create Screen | dart run flutter_architecture_cli create_screen home -f auth |
fvm dart run flutter_architecture_cli create_screen home -f auth |
| Create Model | dart run flutter_architecture_cli create_model user -f auth |
fvm dart run flutter_architecture_cli create_model user -f auth |
| Create Service | dart run flutter_architecture_cli create_service api |
fvm dart run flutter_architecture_cli create_service api |
Features #
- Zero-Configuration Architecture Setup: Instant scaffolding covering storage, networking, localizations, utility helpers, and dependency injection.
- Multi-State Management Support: Full out-of-the-box support for RxDart + Provider (
BehaviorSubjectstream pipelines), flutter_bloc (Bloc<Event, State>,BlocProvider,BlocBuilder), and GetX (GetxController,Bindings,Obx,GetView). - Smart Architecture Auto-Detection: Commands like
create_featureautomatically inspect your project'spubspec.yamlto detect whether you're using BLoC, GetX, or RxDart and generate matching code with 0 configuration. - Centralized Networking: Custom
ApiClientpowered byDiowith automatic logging, secure token handling, and robust exception-handling interceptors. - Common Widget Toolkit: Reusable components such as
AppText,AppImage,AppTextField,AppButton,AppLoader,AppShimmer, andAppNetworkStatusWidget. - Built-in Validation Engine: Comprehensive
Validatorsutility coveringrequired,email,phone,minLength,maxLength,password,numeric,url, andcompose(...)validation chains. - JSON-Based Localization: Fully configured translations with convenient context translation extensions (
context.tr(...)). - FVM Compatible: Effortless compatibility for teams managing Flutter versions with FVM.
Folder Structure #
Generating a project produces this clean, production-ready tree:
lib/
├── common/
│ ├── extensions/ # BuildContext, String, DateTime and Widget extensions
│ ├── helpers/ # Bottom sheets, dialogs, snackbars, and navigation helpers
│ └── widgets/ # Reusable widgets (AppButton, AppLoader, AppText, AppErrorWidget, 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 clean architecture
└── main.dart # Application root bootstrapper
Feature Structure Comparison by State Management:
| RxDart + Provider | flutter_bloc | GetX |
|---|---|---|
lib/src/users/├── bloc/user_bloc.dart├── data_source/user_datasource.dart├── mapper/user_mapper.dart├── model/│ ├── response/user_response.dart│ └── ui_entity/user_ui_entity.dart├── presentation/│ └── view/user_screen.dart├── repository/user_repository.dart└── state/├── user_state.dart└── user_provider.dart |
lib/src/users/├── bloc/│ ├── user_bloc.dart│ ├── user_event.dart│ └── user_state.dart├── data_source/user_datasource.dart├── mapper/user_mapper.dart├── model/│ ├── response/user_response.dart│ └── ui_entity/user_ui_entity.dart├── presentation/│ └── view/user_screen.dart└── repository/user_repository.dart |
lib/src/users/├── binding/user_binding.dart├── controller/user_controller.dart├── data_source/user_datasource.dart├── mapper/user_mapper.dart├── model/│ ├── response/user_response.dart│ └── ui_entity/user_ui_entity.dart├── presentation/│ └── view/user_screen.dart└── repository/user_repository.dart |
State Management Isolation #
In flutter_architecture_cli, state management architectures are 100% strictly segregated. When you select a specific architecture, the generated codebase contains strictly only that architecture's required dependencies and base classes:
Architectural Breakdown by State Choice: #
| Architectural Layer | GetX (--getx or [3]) |
flutter_bloc (--bloc or [2]) |
RxDart + Provider (--state rxdart or [1]) |
|---|---|---|---|
Dependencies in pubspec.yaml |
get: ^4.6.6(Zero rxdart, Zero provider) |
flutter_bloc: ^8.1.6(Zero rxdart, Zero provider) |
rxdart: ^0.28.0provider: ^6.1.5+1 |
Base Classes (lib/core/base/) |
base_mapper.dartbase_ui_state.dart(No base_bloc.dart) |
base_mapper.dartbase_ui_state.dart(No base_bloc.dart) |
base_bloc.dart (CompositeSubscription)base_mapper.dartbase_ui_state.dart |
Dependency Injection (lib/core/di/) |
DependencyInjection.init()Get.put<AppPreferences>(...) |
MultiRepositoryProviderRepositoryProvider<AppPreferences> |
MultiProviderProvider<AppPreferences> |
Application Root (lib/main.dart) |
GetMaterialApp with initialBinding |
MaterialApp with MultiRepositoryProvider |
MaterialApp with MultiProvider |
| Feature Controller / Bloc | GetxController with .obs state |
Bloc<Event, State> with events & states |
BaseBloc with BehaviorSubject & streams |
| UI Presentation Layer | GetView<T> and Obx(() => ...) |
BlocProvider and BlocBuilder |
StreamBuilder and Provider |
| Feature DI Registration | Bindings with Get.lazyPut |
BlocProvider(create: ...) in view |
MultiProvider in _provider.dart |
Smoke Test (test/widget_test.dart) |
pumpWidget(const MyApp()) |
MultiRepositoryProvider pump test |
MultiProvider pump test |
Usage Guide #
You can run commands in two ways depending on how you installed the package:
- As a project dev dependency (Recommended): Prefix with
dart run flutter_architecture_cli(orfvm dart run flutter_architecture_cli). - Globally activated: Run
flutter_architecture_cli <command>directly.
Below is the detailed reference for all 8 available commands.
1. create — Scaffold a New Clean Architecture App #
Creates a complete, production-ready Flutter application with all architectural layers, common widgets, networking, storage, localization, and a working smoke test. Supports RxDart + Provider, flutter_bloc, and GetX.
Interactive State Management Selection:
When running in an interactive terminal, the CLI prompts you to select your preferred architecture:
Select State Management Architecture:
[1] RxDart + Provider (Stream-based) [Default]
[2] flutter_bloc (Event & State based BLoC)
[3] GetX (Reactive Controller & Bindings)
Choose an option (1, 2, or 3) [default: 1]:
Syntax & Options:
# Basic syntax
flutter_architecture_cli create <app_name> [options]
# Options:
# --state State management architecture: 'rxdart', 'bloc', or 'getx' (default: rxdart)
# --bloc Shortcut flag to scaffold using flutter_bloc
# --getx Shortcut flag to scaffold using GetX
# --org Organization reverse-domain (default: com.example)
# --fvm Use FVM (Flutter Version Management) for creation & formatting
# --fvm-version Pin a specific Flutter SDK version in FVM (e.g., 3.22.0)
Examples:
# Interactive creation (prompts for architecture selection)
flutter_architecture_cli create my_shop_app
# Scaffold with GetX directly:
flutter_architecture_cli create my_getx_app --state getx
# or
flutter_architecture_cli create my_getx_app --getx
# Scaffold with flutter_bloc directly:
flutter_architecture_cli create my_bloc_app --state bloc
# or
flutter_architecture_cli create my_bloc_app --bloc
# Scaffold with RxDart + Provider directly:
flutter_architecture_cli create my_shop_app --state rxdart
# With custom package / bundle ID domain
flutter_architecture_cli create my_shop_app --org com.mycompany --getx
# With FVM
flutter_architecture_cli create my_shop_app --fvm
# With FVM and pinned Flutter version
flutter_architecture_cli create my_shop_app --fvm --fvm-version 3.24.0 --bloc
What it generates:
- Full Clean Architecture folder structure (
lib/common/,lib/core/,lib/src/users/). lib/main.dartwith pre-configured DI, Localization, and Theme tailored to your selected architecture.- Strict State Management Isolation: Only the selected architecture's dependencies are installed:
- GetX: Installs only
get: ^4.6.6(no RxDart, no Provider). Uses GetXBindingsandGet.put. - flutter_bloc: Installs only
flutter_bloc: ^8.1.6(no RxDart, no Provider). UsesMultiRepositoryProvider. - RxDart + Provider: Installs
rxdart: ^0.28.0andprovider: ^6.1.5+1.
- GetX: Installs only
- A functional dummy
usersfeature showcasing the full DataSource + Repository + Mapper + UI Entity data flow (usingGetView&Obx,BlocBuilder, orStreamBuilderbased on your selection). - A passing
test/widget_test.dartsmoke test customized for your state management. - Automatically adds
flutter_architecture_cli: ^1.0.5todev_dependenciesinsidepubspec.yaml.
2. create_feature — Generate a Complete Feature Layer #
Instantly creates an entire feature-first folder structure with state management, data, and presentation layers wired together.
Tip
Smart Architecture Auto-Detection: create_feature inspects your pubspec.yaml. If your project includes get:, it automatically generates a GetX Clean Architecture pattern (_controller.dart, _binding.dart, and GetView/Obx view). If it includes flutter_bloc:, it generates the BLoC pattern (_event.dart, _state.dart, _bloc.dart). Otherwise, it generates the RxDart stream pattern! You can also explicitly pass --state <rxdart|bloc|getx>, --bloc, or --getx.
Syntax & Options:
flutter_architecture_cli create_feature <feature_name> [options]
# Options:
# --state State management override ('rxdart', 'bloc', or 'getx')
# --bloc Shortcut flag to force flutter_bloc feature generation
# --getx Shortcut flag to force GetX feature generation
# --fvm Format generated code using FVM
Examples:
# Auto-detects architecture from pubspec.yaml:
dart run flutter_architecture_cli create_feature products
# Explicitly create as GetX:
dart run flutter_architecture_cli create_feature products --getx
# Explicitly create as flutter_bloc:
dart run flutter_architecture_cli create_feature products --bloc
# Explicitly create as RxDart:
dart run flutter_architecture_cli create_feature products --state rxdart
# With FVM
fvm dart run flutter_architecture_cli create_feature products
Generated Structure with GetX:
lib/src/products/
├── binding/
│ └── products_binding.dart # Bindings DI registration (Get.lazyPut)
├── controller/
│ └── products_controller.dart # GetxController with reactive .obs state
├── data_source/
│ └── products_datasource.dart # ApiClient data layer
├── mapper/
│ └── products_mapper.dart # Transforms Response DTO -> UiEntity
├── model/
│ ├── request/ # Request parameter models placeholder
│ ├── response/
│ │ └── products_response.dart # Raw JSON network DTO with fromJson/toJson
│ └── ui_entity/
│ └── products_ui_entity.dart # Clean UI domain entity
├── presentation/
│ ├── view/
│ │ └── products_screen.dart # GetView<ProductsController> with Obx reactive UI
│ └── widget/ # Custom widgets for this feature
└── repository/
└── products_repository.dart # Bridge between DataSource & Controller
Generated Structure with flutter_bloc:
lib/src/products/
├── bloc/
│ ├── products_bloc.dart # Bloc<ProductsEvent, ProductsState>
│ ├── products_event.dart # FetchProductsEvent, etc.
│ └── products_state.dart # BaseUiState subclass with initial/loading/completed/error
├── data_source/
│ └── products_datasource.dart # ApiClient data layer
├── mapper/
│ └── products_mapper.dart # Transforms Response DTO -> UiEntity
├── model/
│ ├── request/ # Request parameter models placeholder
│ ├── response/
│ │ └── products_response.dart # Raw JSON network DTO with fromJson/toJson
│ └── ui_entity/
│ └── products_ui_entity.dart # Clean UI domain entity
├── presentation/
│ ├── view/
│ │ └── products_screen.dart # BlocProvider + BlocBuilder view with Loader & Error
│ └── widget/ # Custom widgets for this feature
└── repository/
└── products_repository.dart # Bridge between DataSource & Bloc
Generated Structure with RxDart + Provider:
lib/src/products/
├── bloc/
│ └── products_bloc.dart # RxDart BehaviorSubject state emitter
├── data_source/
│ └── products_datasource.dart # ApiClient data layer
├── mapper/
│ └── products_mapper.dart # Transforms Response DTO -> UiEntity
├── model/
│ ├── request/ # Request parameter models placeholder
│ ├── response/
│ │ └── products_response.dart # Raw JSON network DTO with fromJson/toJson
│ └── ui_entity/
│ └── products_ui_entity.dart # Clean UI domain entity
├── presentation/
│ ├── view/
│ │ └── products_screen.dart # StreamBuilder view with AppText, Loader & ErrorWidget
│ └── widget/ # Custom widgets for this feature
├── repository/
│ └── products_repository.dart # Bridge between DataSource & Bloc
└── state/
├── products_state.dart # BaseUiState subclass (loading, completed, error)
└── products_provider.dart # Provider DI wire-up
How to consume the generated feature in your app:
-
GetX:
import 'package:my_app/src/products/presentation/view/products_screen.dart'; import 'package:my_app/src/products/binding/products_binding.dart'; // Direct navigation with binding: Get.to(() => const ProductsScreen(), binding: ProductsBinding()); // Or in your GetPage route definition: GetPage( name: '/products', page: () => const ProductsScreen(), binding: ProductsBinding(), ); -
flutter_bloc:
import 'package:my_app/src/products/presentation/view/products_screen.dart'; // The generated screen automatically initializes its BlocProvider: Navigator.push( context, MaterialPageRoute(builder: (_) => const ProductsScreen()), ); -
RxDart + Provider:
import 'package:my_app/src/products/presentation/view/products_screen.dart'; import 'package:my_app/src/products/state/products_provider.dart'; // Wrap the screen in its feature MultiProvider: Navigator.push( context, MaterialPageRoute( builder: (_) => MultiProvider( providers: ProductsProvider.providers, child: const ProductsScreen(), ), ), );
3. create_screen — Add a Presentation Screen #
Adds a new screen widget to an existing or new feature's presentation layer.
Syntax & Options:
flutter_architecture_cli create_screen <screen_name> -f <feature_name> [--fvm]
# Options:
# -f, --feature The target feature folder inside lib/src/ (defaults to screen name)
# --fvm Format generated code using FVM
Examples:
# Create "checkout_screen.dart" inside lib/src/cart/presentation/view/
flutter_architecture_cli create_screen checkout -f cart
# Using dart run
dart run flutter_architecture_cli create_screen profile_settings -f profile
# Using FVM
fvm dart run flutter_architecture_cli create_screen product_details -f products
What it generates:
- Generates
lib/src/<feature>/presentation/view/<screen_name>_screen.dart. - Includes a clean
StatelessWidgetwithScaffold,AppBar,AppText, and a staticrouteName.
4. create_model — Generate UI Entity and Response DTO #
Generates both the UI Entity (domain model) and the Response Model (with JSON serialization).
Syntax & Options:
flutter_architecture_cli create_model <model_name> -f <feature_name> [--fvm]
# Options:
# -f, --feature The target feature folder inside lib/src/
# --fvm Format generated code using FVM
Examples:
# Generate product_ui_entity.dart and product_response.dart
flutter_architecture_cli create_model product -f products
# Using dart run
dart run flutter_architecture_cli create_model order -f orders
What it generates:
lib/src/<feature>/model/ui_entity/<model_name>_ui_entity.dart— Clean model for UI consumption.lib/src/<feature>/model/response/<model_name>_response.dart— Network DTO withfromJson()andtoJson()methods.
5. create_datasource — Generate an API Data Source #
Creates an API data source class wired with the singleton ApiClient.
Syntax & Options:
flutter_architecture_cli create_datasource <name> -f <feature_name> [--fvm]
# Options:
# -f, --feature The target feature folder inside lib/src/
# --fvm Format generated code using FVM
Examples:
# Generate payment_datasource.dart in lib/src/payment/data_source/
flutter_architecture_cli create_datasource payment -f payment
# Using dart run
dart run flutter_architecture_cli create_datasource order -f orders
What it generates:
lib/src/<feature>/data_source/<name>_datasource.dartwithfinal ApiClient _apiClient = ApiClient.instance;.
6. create_repository — Generate a Repository #
Generates a repository class bridging your DataSource and Bloc. It automatically scans your feature directory and links to any existing data sources to avoid manual import wiring.
Syntax & Options:
flutter_architecture_cli create_repository <name> -f <feature_name> [--fvm]
# Options:
# -f, --feature The target feature folder inside lib/src/
# --fvm Format generated code using FVM
Examples:
# Generate cart_repository.dart in lib/src/cart/repository/
flutter_architecture_cli create_repository cart -f cart
# Using dart run
dart run flutter_architecture_cli create_repository order -f orders
What it generates:
lib/src/<feature>/repository/<name>_repository.dart- Automatically discovers and injects the feature's data source:
import 'package:my_app/src/cart/data_source/cart_datasource.dart'; class CartRepository { final CartDataSource _dataSource = CartDataSource(); // Add repository operations }
7. create_service — Generate a Core Singleton Service #
Generates a core application service using the thread-safe singleton pattern in lib/core/services/.
Syntax & Options:
flutter_architecture_cli create_service <service_name> [--fvm]
# Options:
# --fvm Format generated code using FVM
Examples:
# Create auth_service.dart in lib/core/services/
flutter_architecture_cli create_service auth
# Create analytics_service.dart using dart run
dart run flutter_architecture_cli create_service analytics
# Using FVM
fvm dart run flutter_architecture_cli create_service notification
What it generates:
lib/core/services/<service_name>_service.dart:
class AuthService {
static final AuthService _instance = AuthService._internal();
factory AuthService() => _instance;
AuthService._internal();
Future<void> init() async {
// Service initialization logic
}
}
8. change_bundle_id — Rename Package Name / Bundle ID #
Safely updates the Android application ID/namespace and iOS bundle identifier across the entire project in one step.
Syntax & Options:
flutter_architecture_cli change_bundle_id <new_bundle_id>
Examples:
# Global CLI
flutter_architecture_cli change_bundle_id com.mycompany.shopapp
# As Dev Dependency (Standard)
dart run flutter_architecture_cli change_bundle_id com.mycompany.shopapp
# As Dev Dependency (FVM)
fvm dart run flutter_architecture_cli change_bundle_id com.mycompany.shopapp
What it updates automatically:
- Android:
android/app/build.gradle(applicationId,namespace).android/app/build.gradle.kts(Kotlin DSL support).android/app/src/main/AndroidManifest.xml(package="...").- Moves
MainActivity.ktorMainActivity.javato the new package directory structure and cleans up old empty folders.
- iOS:
ios/Runner.xcodeproj/project.pbxproj(PRODUCT_BUNDLE_IDENTIFIER).
Architecture Flow #
The generated structure focuses on a single directional clean architecture data flow:
- DataSource: Fetches raw JSON data using
ApiClientand parses it into a Response DTO (model/response/). - Mapper: Inherits from
BaseMapperto transform the Response DTO into a clean UI Entity (model/ui_entity/). - Repository: Requests data from
DataSourceand runs the mapped results up to the state management layer. - State Management:
- RxDart + Provider: Converts repository streams into
BaseUiState(Loading -> Completed/Error) emitted viaBehaviorSubject. - flutter_bloc: Handles incoming
Events and emits state extendingBaseUiStateviaBloc<Event, State>. - GetX: Manages reactive
BaseUiStatevia.obsinsideGetxController, with dependency injection handled viaBindings.
- RxDart + Provider: Converts repository streams into
- Presentation (View):
- RxDart: Listens to the Bloc subjects using
StreamBuilderand renders loading, success, or error screens automatically. - flutter_bloc: Rebuilds on state transitions using
BlocProviderandBlocBuilder. - GetX: Automatically reacts to state changes using
GetViewandObx(() => ...).
- RxDart: Listens to the Bloc subjects using
Form Validation Helper #
Every scaffolded application includes lib/core/utils/validators.dart, providing a robust, pre-built validation engine. It integrates seamlessly with AppTextField and Flutter's standard TextFormField:
import 'package:my_app/core/utils/validators.dart';
// 1. Direct validation functions
AppTextField(
labelText: 'Email',
validator: Validators.email,
)
// 2. Custom error messages
AppTextField(
labelText: 'Username',
validator: (val) => Validators.required(val, 'Username is required'),
)
// 3. Length constraints
AppTextField(
labelText: 'Bio',
validator: (val) => Validators.maxLength(val, 150),
)
// 4. Password validation (with optional number & special character checks)
AppTextField(
labelText: 'Password',
isPassword: true,
validator: (val) => Validators.password(
val,
minLength: 8,
requireNumber: true,
requireSpecialChar: true,
),
)
// 5. Password Confirmation Matching
AppTextField(
labelText: 'Confirm Password',
isPassword: true,
validator: (val) => Validators.match(val, passwordController.text, 'Passwords do not match'),
)
// 6. Chained validation rules (executes sequentially)
AppTextField(
labelText: 'Work Email',
validator: Validators.compose([
Validators.required,
Validators.email,
]),
)
Available Validator Methods: #
Validators.required(value, [message])— Validates non-empty input.Validators.email(value, [message])— Validates RFC-compliant email address format.Validators.phone(value, [message])— Validates 10-12 digit phone numbers.Validators.minLength(value, min, [message])— Enforces minimum character length.Validators.maxLength(value, max, [message])— Enforces maximum character length limit.Validators.password(value, {minLength, requireNumber, requireSpecialChar, message})— Validates password complexity.Validators.match(value, target, [message])— Validates that two inputs match (e.g. password confirmation).Validators.numeric(value, [message])— Ensures input contains only numeric digits.Validators.url(value, [message])— Ensures valid HTTP/HTTPS URL syntax.Validators.compose([...])— Sequentially executes a list of validator functions and returns the first error encountered.
Roadmap / Future Goals #
We plan to expand the CLI tool to support multiple popular state management architectures:
- ✅ flutter_bloc: Support for Bloc/Event/State architecture with
BlocBuilderandBlocProvider(Added in v1.0.5). - ✅ GetX: Support for reactive controller, bindings, and
Obx/GetView(Added in v1.0.5). - ❌ Riverpod: Support for modern declarative state management and providers.
- ❌ Custom templates: Ability to load user-defined boilerplate structures.
Contributing #
Contributions are welcome! If you want to suggest an improvement, report a bug, or add new command options:
- Fork the repository:
https://github.com/Dharti1623/flutter_architecture_cli - Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - 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:
- ☕ Buy Me A Coffee: https://buymeacoffee.com/dhartichauhan
- ⭐ Star the Repository: Show your support by giving our Github repository a star!