flab 1.0.4
flab: ^1.0.4 copied to clipboard
A CLI tool to scaffold Flutter projects with Clean Architecture, MVVM, MVC, and custom themes.
๐ FLAB CLI (Flutter Architecture & Booster) #
FLAB is an enterprise-grade Command Line Interface (CLI) tool designed to accelerate Flutter application development. It automates project initialization, feature scaffolding across multiple architecture patterns (Clean Architecture, MVVM, MVC), dependency injection setup, production-ready theme engines, responsive utilities, networking, and offline caching.
๐ Table of Contents #
- Features
- Installation
- Quick Start
- Architecture & Folder Structure
- Command Reference
- Pre-configured Tech Stack
- CLI Command Cheat Sheet
- Contributing
- License
- Author
โจ Features #
- โก Full Project Bootstrapping (
flab init): Generate a production-ready Flutter app with pre-installed industry standard packages, structured asset directories, routing, theme systems, and dependency injection in seconds. - ๐๏ธ Multi-Architecture Support:
- Clean Architecture (Data, Domain, and Presentation separation).
- MVVM (Model-View-ViewModel).
- MVC (Model-View-Controller).
- ๐ Automated Dependency Injection: Automatically updates
lib/injection.dart(GetIt) when adding, renaming, or removing features without manual registration boilerplate. - ๐จ Enterprise Theme & Design System: Complete light & dark mode setups, typography with
flutter_screenutil, curated color palette (UColors), spacing/sizes (USizes), and individual widget themes (AppBar, Buttons, BottomSheet, Checkbox, Chip, TextField). - ๐ Production Networking & Storage:
- Pre-configured
DioClientwith logging (PrettyDioLogger), token management, custom error interceptors, and timeouts. - Offline local caching via
Hive(StorageService). - Network connectivity checker (
NetworkInfoviaconnectivity_plus).
- Pre-configured
- ๐ ๏ธ Context Extensions & Helpers: Device screen utilities, orientation handlers, responsive helpers, snackbars, and navigation shortcuts via
UDeviceHelperandBuildContextextensions. - ๐งน Project Maintenance Tools: Visual tree generator (
flab tree), environment health check (flab doctor), and pubspec comment cleaner with asset auto-registration (flab clean pubspec).
๐ฆ Installation #
Global Activation via Pub #
Activate flab globally using the Dart package manager:
dart pub global activate flab
Install from Source (GitHub) #
dart pub global activate --source git https://github.com/rafsanul247/flab_cli.git
Verify Installation #
Check if the CLI is accessible from your terminal:
flab --version
# Output: FLAB CLI Version: 1.0.4
flab --help
Note: Ensure your Dart global pub cache directory is added to your system's
PATHenvironment variable:
- Windows:
%LOCALAPPDATA%\Pub\Cache\bin- macOS / Linux:
$HOME/.pub-cache/bin
๐ Quick Start #
1. Create and Configure a New Project #
Initialize a new Flutter project named my_app:
flab init my_app
This command will:
- Run
flutter create my_app. - Clean
pubspec.yamland configure asset directories. - Automatically install:
dio,hive,hive_flutter,get_it,go_router,google_fonts,connectivity_plus,pretty_dio_logger, andflutter_screenutil. - Generate the full
corearchitecture (Themes, Constants, Routes, Network, Hive, Helpers). - Set up
lib/injection.dart,lib/app.dart, andlib/main.dart. - Fix
test/widget_test.dartto link with the new entry point.
2. Configure an Existing Flutter Project #
Navigate to your existing Flutter project and run:
cd existing_flutter_project
flab init
3. Generate Features #
Generate a Clean Architecture feature with the default GetX state management:
flab authentication
To choose Provider, Riverpod, GetX, or Bloc interactively:
flab authentication --clean
flab profile --mvvm
flab dashboard --mvc
๐๏ธ Architecture & Folder Structure #
Generated Project Structure #
my_app/
โโโ assets/
โ โโโ animations/
โ โโโ icons/
โ โโโ images/
โโโ lib/
โ โโโ core/
โ โ โโโ constants/
โ โ โ โโโ colors.dart # UColors palette
โ โ โ โโโ sizes.dart # USizes responsive constants
โ โ โ โโโ texts.dart # App strings & labels
โ โ โโโ extensions/
โ โ โ โโโ context_extension.dart # BuildContext helpers (themes, navigation, dimensions)
โ โ โโโ helpers/
โ โ โ โโโ device_helpers.dart # UDeviceHelper (platform, keyboard, screen metrics)
โ โ โโโ network/
โ โ โ โโโ dio_client.dart # Configured Dio with interceptors & logger
โ โ โ โโโ network_info.dart # Connectivity monitor
โ โ โโโ routes/
โ โ โ โโโ app_router.dart # GoRouter configuration & routes
โ โ โโโ services/
โ โ โ โโโ hive_service.dart # StorageService with Hive box operations
โ โ โโโ theme/
โ โ โ โโโ app_theme.dart # UAppTheme (light & dark theme data)
โ โ โ โโโ text_theme.dart # UTextTheme responsive text typography
โ โ โ โโโ widgets_theme/ # Modular component themes
โ โ โ โโโ appbar_theme.dart
โ โ โ โโโ botton_sheet_theme.dart
โ โ โ โโโ checkbox_theme.dart
โ โ โ โโโ chip_theme.dart
โ โ โ โโโ elevated_button_theme.dart
โ โ โ โโโ outlined_button_theme.dart
โ โ โ โโโ text_field_theme.dart
โ โ โโโ utils/
โ โ โโโ api_endpoint.dart # Base URLs and endpoint constants
โ โ โโโ app_logger.dart # Colored console logger
โ โโโ features/ # Application features / modules
โ โโโ app.dart # ScreenUtilInit & MaterialApp.router setup
โ โโโ injection.dart # GetIt service locator registrations
โ โโโ main.dart # Application bootstrap with Hive & DI init
โโโ test/
โ โโโ widget_test.dart # Synchronized test configuration
โโโ pubspec.yaml # Cleaned dependencies & registered assets
Clean Architecture Feature Structure #
When running flab <feature_name> or flab <feature_name> --clean:
lib/features/<feature_name>/
โโโ data/
โ โโโ data_sources/
โ โ โโโ <feature_name>_data_source.dart # Remote/Local data source contract & Dio implementation
โ โโโ models/
โ โ โโโ <feature_name>_model.dart # JSON serialization model
โ โโโ repositories/
โ โโโ <feature_name>_repository_implement.dart # Concrete repository implementation
โโโ domain/
โ โโโ entities/
โ โ โโโ <feature_name>_entity.dart # Core business entity
โ โโโ repositories/
โ โ โโโ <feature_name>_repository.dart # Abstract repository interface
โ โโโ usecases/
โ โโโ <feature_name>_usecase.dart # Business logic use cases
โโโ presentation/
โโโ manager/ # Generated for Clean + GetX
โ โโโ controller/
โ โโโ <feature_name>_controller.dart # GetX feature controller/state holder
โโโ views/
โโโ widgets/ # Feature-specific widgets
โโโ <feature_name>_screen.dart # UI view screen
โโโ state/
โโโ <feature_name>_<state_management>.dart # Provider, Riverpod, or Bloc starter
For Clean Architecture with GetX, the manager controller is used as the state holder, so no separate presentation/state GetX file is generated. When Provider, Riverpod, or Bloc is selected, the matching starter state file is generated instead.
๐ป Command Reference #
1. Project Initialization (init) #
Initialize a brand new Flutter project or inject FLAB architecture into an existing one:
# Create a new Flutter app with complete setup
flab init <app_name>
# Initialize within current Flutter directory
flab init
2. Feature Scaffolding #
Scaffold features according to your preferred architectural pattern:
Clean Architecture with GetX (Default)
flab auth
Generates Clean Architecture layers with a manager controller and installs the
getpackage.
Clean Architecture with Selected State Management
flab auth --clean
The CLI asks you to choose Provider, Riverpod, GetX, or Bloc and installs the matching package. Provider, Riverpod, and Bloc generate a starter state file; GetX uses the manager controller instead.
MVVM Architecture
flab profile --mvvm
The CLI asks you to choose Provider, Riverpod, GetX, or Bloc, installs the matching package, and generates models/, viewmodels/, views/, and a state-management starter file.
MVC Architecture
flab dashboard --mvc
The CLI asks you to choose Provider, Riverpod, GetX, or Bloc, installs the matching package, and generates models/, controllers/, views/, and a state-management starter file with starter MVC model and controller classes.
Granular Component Generation
Generate specific components directly inside a feature:
# Generate a dedicated UseCase inside lib/features/auth/domain/usecases/
flab auth -u LoginUser
# Generate Model & Entity inside data/models and domain/entities
flab auth -m User
3. Feature Lifecycle Management #
Keep your codebase clean with automated feature management:
# List all active features
flab list
# Safely delete a feature (removes folder, test directory, and unbinds from injection.dart)
flab rm <feature_name>
# Rename a feature (renames folder, updates imports, and re-registers in injection.dart)
flab rename <old_name> <new_name>
4. Modular Configuration (config) #
Inject specific architectural modules individually into any Flutter project:
# Injects themes, constants, widgets_theme, helpers, context extension, and router
flab config theme
# Creates assets/animations, assets/icons, and assets/images directories
flab config assets
# Sets up Dio client, NetworkInfo, Hive StorageService, and lib/injection.dart
flab config backend
# Injects ApiEndpoints and AppLogger
flab config utils
# Injects production-ready app.dart and main.dart (with ScreenUtil & GoRouter integration)
flab config main
5. Pubspec Optimization (clean pubspec) #
Cleans up boilerplate comments generated by Flutter in pubspec.yaml, automatically configures asset directories, and ensures proper YAML structure:
flab clean pubspec
6. Diagnostics & Utilities (doctor, tree) #
# Check if the current environment is a valid Flutter workspace
flab doctor
# or
flab health
# Display an ASCII tree diagram of the lib/ folder
flab tree
๐ ๏ธ Pre-configured Tech Stack #
Projects created or configured with flab come pre-equipped with industry standard, production-ready packages:
| Package | Purpose |
|---|---|
get_it |
Fast Service Locator for Dependency Injection |
go_router |
Declarative routing package for Flutter |
dio |
Powerful HTTP client with interceptors & global configuration |
dartz |
Functional programming โ Either for typed error handling |
pretty_dio_logger |
Formatted network request and response logging |
hive & hive_flutter |
Lightweight and blazingly fast key-value offline storage |
flutter_screenutil |
Responsive UI adaptation and text scaling |
google_fonts |
Modern typography and font management |
connectivity_plus |
Network connectivity monitoring |
get |
Default GetX state management for features |
provider |
Optional state management selected during scaffolding |
flutter_riverpod |
Optional state management selected during scaffolding |
flutter_bloc |
Optional state management selected during scaffolding |
๐ CLI Command Cheat Sheet #
| Command | Arguments / Flags | Description |
|---|---|---|
flab init |
[appName] |
Initialize new or configure current Flutter project |
flab <feature> |
โ | Clean Architecture with GetX by default |
flab <feature> |
--clean |
Clean Architecture with interactive state-management selection |
flab <feature> |
--mvvm |
MVVM with interactive state-management selection |
flab <feature> |
--mvc |
MVC with interactive state-management selection |
flab <feature> |
-u, --usecase <Name> |
Generate a dedicated UseCase file |
flab <feature> |
-m, --model <Name> |
Generate Model and Entity files |
flab list |
โ | List all existing features |
flab rm |
<feature> |
Remove feature directory and unbind from injection.dart |
flab rename |
<old> <new> |
Rename feature directory and update injection.dart |
flab config theme |
โ | Inject theme engine, colors, sizes, and context extensions |
flab config assets |
โ | Create standardized asset folder structure |
flab config backend |
โ | Inject Dio, Hive storage service, and DI skeleton |
flab config utils |
โ | Inject API endpoints and logger utilities |
flab config main |
โ | Inject responsive main.dart and app.dart |
flab clean pubspec |
โ | Remove comments from pubspec & link assets automatically |
flab doctor |
โ | Run environment diagnostics |
flab tree |
โ | Print visual directory hierarchy of lib/ |
flab --help, -h |
โ | Show CLI help guide |
flab --version, -v |
โ | Show installed FLAB version |
๐ค Contributing #
Contributions, issues, and feature requests are welcome!
- Fork the repository on GitHub.
- Create your feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'feat: add amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Author #
Rafsanul Rifat
- GitHub: @rafsanul247
- Repository: rafsanul247/flab_cli