Skip to main content

flab 1.0.4 copy "flab: ^1.0.4" to clipboard
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) #

Pub Version Dart SDK License: MIT GitHub

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 #

  • โšก 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 DioClient with logging (PrettyDioLogger), token management, custom error interceptors, and timeouts.
    • Offline local caching via Hive (StorageService).
    • Network connectivity checker (NetworkInfo via connectivity_plus).
  • ๐Ÿ› ๏ธ Context Extensions & Helpers: Device screen utilities, orientation handlers, responsive helpers, snackbars, and navigation shortcuts via UDeviceHelper and BuildContext extensions.
  • ๐Ÿงน 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 PATH environment 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:

  1. Run flutter create my_app.
  2. Clean pubspec.yaml and configure asset directories.
  3. Automatically install: dio, hive, hive_flutter, get_it, go_router, google_fonts, connectivity_plus, pretty_dio_logger, and flutter_screenutil.
  4. Generate the full core architecture (Themes, Constants, Routes, Network, Hive, Helpers).
  5. Set up lib/injection.dart, lib/app.dart, and lib/main.dart.
  6. Fix test/widget_test.dart to 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 get package.

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!

  1. Fork the repository on GitHub.
  2. Create your feature branch (git checkout -b feature/amazing-feature).
  3. Commit your changes (git commit -m 'feat: add amazing feature').
  4. Push to the branch (git push origin feature/amazing-feature).
  5. Open a Pull Request.

๐Ÿ“„ License #

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ‘ค Author #

Rafsanul Rifat

5
likes
160
points
174
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A CLI tool to scaffold Flutter projects with Clean Architecture, MVVM, MVC, and custom themes.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

args, cli_dialog, io, mason_logger, path

More

Packages that depend on flab