Skip to main content

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

A production-ready Flutter CLI and architecture kit for Clean Architecture, BLoC, API, and project scaffolding.

Flutter Architecture Kit ๐Ÿ—๏ธ #

A production-ready Flutter CLI and architecture kit for generating and maintaining Clean Architecture, BLoC, API layers, and enterprise project scaffolding.

Pub Version Dart SDK Flutter License: MIT Tests Passing Effective Dart


๐Ÿ“– Introduction #

Flutter Architecture Kit (flutter-architect) is a developer CLI inspired by Angular CLI, Rails generators, and Mason scaffolding. It automates the generation and maintenance of scalable Clean Architecture + BLoC + Feature-first Flutter projects.

Instead of writing repetitive boilerplate or relying on unstructured folder copiers, Flutter Architecture Kit generates real, strongly typed, compilable Dart code with modern error handling (Result<T>, typed failures), Dio networking with interceptors, GetIt dependency injection, Material 3 theming, build flavors, and CI/CD validation.

๐Ÿ’ก Design Philosophy: By default, Flutter Architecture Kit does not generate an entities/ folder, eliminating redundant model-to-entity mapping boilerplate in 95% of real-world apps while preserving strict architectural boundaries between Domain, Data, and Presentation.


๐Ÿ’ก Why Flutter Architecture Kit? #

Problem in Flutter Teams Solution with Flutter Architecture Kit
Architectural Drift Enforces a strict, consistent Clean Architecture structure across all features.
Boilerplate Fatigue Generates working BLoCs, Models, Repositories, UseCases, and DataSources in 1 command.
Broken Layer Boundaries Built-in flutter-architect validate prevents Domain from importing Presentation or UI.
Silent Overwrites Safe collision resolver with interactive prompts, --force, --skip-existing, and --dry-run.
Relative Import Hell Automatically reads pubspec.yaml to generate clean package:my_app/... imports.
CI/CD Quality Control Run flutter-architect validate in GitHub Actions to stop malformed PRs.

๐Ÿ›๏ธ Architecture Overview #

Flutter Architecture Kit scaffolds a modular Clean Architecture with a Feature-first organization:

graph TD
    subgraph Presentation Layer
        UI[Page / Screen Widget] -->|Dispatches Events| BLoC[BLoC / Cubit]
        BLoC -->|Emits States| UI
    end

    subgraph Domain Layer
        BLoC -->|Executes| UC[Use Case]
        UC -->|Calls Contract| RI[Repository Interface]
    end

    subgraph Data Layer
        RImpl[Repository Implementation] -.->|Implements| RI
        RImpl -->|Fetches Data| RDS[Remote Data Source]
        RImpl -->|Caches Data| LDS[Local Data Source]
        RDS -->|HTTP Calls| DIO[Dio Client]
        LDS -->|Key-Value Storage| PREF[Local Storage]
    end

The 4 Core Layers #

  1. Presentation (lib/features/<name>/presentation/): Contains Pages, Widgets, Dialogs, BottomSheets, and BLoC/Cubit state management. Strictly UI and state handling; never communicates with DataSources directly.
  2. Domain (lib/features/<name>/domain/): The business core of the application. Contains UseCases and Repository interfaces. Pure Dart, free from Flutter UI framework dependencies.
  3. Data (lib/features/<name>/data/): Implements domain repository contracts. Coordinates between Remote DataSources (REST API/Dio) and Local DataSources (Cache). Defines serialization Models.
  4. Core (lib/core/): Shared infrastructure across all features: Network clients, Error/Failure classes, Design tokens, Routing, and Extensions.

๐Ÿ“ฆ Installation #

Activate flutter_architecture_kit globally using the Dart SDK:

dart pub global activate flutter_architecture_kit

Make sure your system PATH contains the pub cache bin directory:

  • macOS / Linux: ~/.pub-cache/bin
  • Windows: %LOCALAPPDATA%\Pub\Cache\bin

Verify installation (both flutter-architect and flutter-architecture-kit binaries are available):

flutter-architect --version
# or
flutter-architecture-kit --version

๐Ÿš€ Quick Start #

1. In a New Flutter Project #

# 1. Create a Flutter project
flutter create my_shop
cd my_shop

# 2. Initialize Clean Architecture scaffolding
flutter-architect init

# 3. Add core dependencies
flutter pub add flutter_bloc dio get_it

# 4. Generate your first feature
flutter-architect feature catalog

2. In an Existing Flutter Project #

Flutter Architect is 100% safe to run inside existing Flutter projects. It never overwrites your existing files without confirmation:

cd existing_project
flutter-architect init --skip-existing
flutter-architect feature user_profile
flutter-architect doctor

๐Ÿ’ป Interactive Setup (init) #

Running flutter-architect init launches an interactive wizard:

Flutter Architect

? Project architecture:
  > 1) Clean Architecture
    2) Feature-first

? State management:
  > 1) BLoC
    2) Cubit
    3) None

? Networking:
  > 1) Dio
    2) None

? Dependency injection:
  > 1) GetIt
    2) None

? Theme:
  > 1) Material 3 + Light/Dark
    2) Standard

? Generate example feature (auth)? (Y/n): Y

Creating Flutter architecture...
โœ“ Created lib/core/error/failures.dart
โœ“ Created lib/core/error/exceptions.dart
โœ“ Created lib/core/utils/result.dart
โœ“ Created lib/core/constants/app_constants.dart
โœ“ Created lib/core/extensions/context_extensions.dart
โœ“ Created lib/core/network/dio_client.dart
โœ“ Created lib/core/theme/app_theme.dart
โœ“ Created lib/injection/injection_container.dart
โœ“ Created lib/features/auth/...

Flutter Architect project initialized successfully.

Non-Interactive / Automation Mode (CI/CD) #

All interactive prompts can be bypassed using command-line arguments:

flutter-architect init \
  --architecture clean \
  --state-management bloc \
  --network dio \
  --di get_it \
  --theme material3 \
  --example-feature \
  --force

๐Ÿ—‚๏ธ Complete Generated Folder Tree #

lib/
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ constants/
โ”‚   โ”‚   โ””โ”€โ”€ app_constants.dart             # Storage keys, timeouts, app metadata
โ”‚   โ”œโ”€โ”€ error/
โ”‚   โ”‚   โ”œโ”€โ”€ exceptions.dart                # ServerException, CacheException, NetworkException
โ”‚   โ”‚   โ””โ”€โ”€ failures.dart                  # ServerFailure, CacheFailure, ValidationFailure
โ”‚   โ”œโ”€โ”€ extensions/
โ”‚   โ”‚   โ””โ”€โ”€ context_extensions.dart        # BuildContext shortcuts: theme, colorScheme, textTheme
โ”‚   โ”œโ”€โ”€ network/
โ”‚   โ”‚   โ”œโ”€โ”€ api_endpoints.dart             # Centralized API URLs and paths
โ”‚   โ”‚   โ”œโ”€โ”€ dio_client.dart                # Configured Dio instance with timeouts & headers
โ”‚   โ”‚   โ”œโ”€โ”€ network_info.dart              # Connectivity checker abstraction
โ”‚   โ”‚   โ””โ”€โ”€ interceptors/
โ”‚   โ”‚       โ”œโ”€โ”€ error_interceptor.dart     # Auto-maps Dio errors to typed ServerExceptions
โ”‚   โ”‚       โ””โ”€โ”€ logging_interceptor.dart   # Pretty curl/request/response logs in debug mode
โ”‚   โ”œโ”€โ”€ routing/
โ”‚   โ”‚   โ””โ”€โ”€ app_router.dart                # Declarative route generator
โ”‚   โ”œโ”€โ”€ theme/
โ”‚   โ”‚   โ”œโ”€โ”€ app_colors.dart                # Material 3 color palettes
โ”‚   โ”‚   โ”œโ”€โ”€ app_text_styles.dart           # Typography scale
โ”‚   โ”‚   โ”œโ”€โ”€ app_theme_mode.dart            # Light, Dark, System enum
โ”‚   โ”‚   โ””โ”€โ”€ app_theme.dart                 # lightTheme and darkTheme ThemeData definitions
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ””โ”€โ”€ result.dart                    # Modern Dart 3 functional Result<T> (Success/Failure)
โ”‚   โ””โ”€โ”€ widgets/
โ”‚       โ”œโ”€โ”€ error_view.dart                # Generic error display with retry callback
โ”‚       โ””โ”€โ”€ loading_indicator.dart         # Styled progress indicator
โ”‚
โ”œโ”€โ”€ features/
โ”‚   โ””โ”€โ”€ auth/                              # Feature-first module
โ”‚       โ”œโ”€โ”€ data/
โ”‚       โ”‚   โ”œโ”€โ”€ datasources/
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ auth_remote_datasource.dart # Dio API calls
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ auth_local_datasource.dart  # Local cache/storage
โ”‚       โ”‚   โ”œโ”€โ”€ models/
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ auth_model.dart             # fromJson, toJson, copyWith
โ”‚       โ”‚   โ””โ”€โ”€ repositories/
โ”‚       โ”‚       โ””โ”€โ”€ auth_repository_impl.dart   # Implements domain repository contract
โ”‚       โ”œโ”€โ”€ domain/
โ”‚       โ”‚   โ”œโ”€โ”€ repositories/
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ auth_repository.dart        # Pure domain interface
โ”‚       โ”‚   โ””โ”€โ”€ usecases/
โ”‚       โ”‚       โ””โ”€โ”€ get_auth_usecase.dart       # Single-responsibility usecase
โ”‚       โ””โ”€โ”€ presentation/
โ”‚           โ”œโ”€โ”€ bloc/
โ”‚           โ”‚   โ”œโ”€โ”€ auth_bloc.dart              # Modern Bloc with event handlers
โ”‚           โ”‚   โ”œโ”€โ”€ auth_event.dart             # Sealed events
โ”‚           โ”‚   โ””โ”€โ”€ auth_state.dart             # Initial, Loading, Loaded, Error states
โ”‚           โ”œโ”€โ”€ pages/
โ”‚           โ”‚   โ””โ”€โ”€ auth_page.dart              # BlocConsumer page with loading & error states
โ”‚           โ””โ”€โ”€ widgets/
โ”‚               โ””โ”€โ”€ auth_item_view.dart         # Reusable card widget
โ”‚
โ”œโ”€โ”€ injection/
โ”‚   โ””โ”€โ”€ injection_container.dart           # GetIt service locator setup
โ”‚
โ”œโ”€โ”€ .env                                   # Local environment variables
โ”œโ”€โ”€ .env.example                           # Template environment configuration
โ”œโ”€โ”€ flutter_architect.yaml                 # Project architecture configuration
โ””โ”€โ”€ main.dart                              # Application entrypoint

๐Ÿ› ๏ธ Complete Command Reference #

Project Lifecycle Commands #

flutter-architect init

Scaffolds Clean Architecture in the current directory.

flutter-architect init [options]
# Options:
#   -a, --architecture       [clean | feature_first] (default: clean)
#   -s, --state-management   [bloc | cubit | none]   (default: bloc)
#   -n, --network            [dio | none]            (default: dio)
#   -d, --di                 [get_it | none]         (default: get_it)
#   -t, --theme              [material3 | standard]  (default: material3)
#       --example-feature    Generate example auth feature (default: true)
#   -f, --force              Overwrite files without prompting
#       --dry-run            Preview generated files without touching disk

flutter-architect configure

Inspect or update settings in flutter_architect.yaml.

# View configuration
flutter-architect configure --show

# Update state management to Cubit
flutter-architect configure --state-management cubit

flutter-architect doctor

Runs comprehensive environment and project diagnostics.

flutter-architect doctor

Checks:

  • Dart SDK & version
  • Flutter SDK & version
  • pubspec.yaml detection
  • flutter_architect.yaml configuration validity
  • Presence of flutter_bloc, dio, and get_it dependencies

flutter-architect validate

Validates architecture layer boundaries and naming conventions. Exits with code 0 on success or 65 on error. Ideal for CI/CD pipelines!

flutter-architect validate

flutter-architect version

Prints current CLI version.

flutter-architect version

Architecture & Feature Commands #

flutter-architect feature <name>

Scaffolds a complete Clean Architecture feature bundle (Data, Domain, Presentation).

flutter-architect feature product_detail

# Preview before writing:
flutter-architect feature product_detail --dry-run

Generates:

  • data/models/product_detail_model.dart
  • data/datasources/product_detail_remote_datasource.dart
  • data/datasources/product_detail_local_datasource.dart
  • domain/repositories/product_detail_repository.dart
  • data/repositories/product_detail_repository_impl.dart
  • domain/usecases/get_product_detail_usecase.dart
  • presentation/bloc/product_detail_bloc.dart
  • presentation/bloc/product_detail_event.dart
  • presentation/bloc/product_detail_state.dart
  • presentation/pages/product_detail_page.dart
  • presentation/widgets/product_detail_item_view.dart

flutter-architect module <name>

Generates an isolated modular architecture package.

flutter-architect module analytics

State Management Commands #

flutter-architect bloc <name>

Generates modern flutter_bloc 8.x/9.x classes with Initial, Loading, Loaded, and Error states.

flutter-architect bloc cart --feature shopping

flutter-architect cubit <name>

Generates a Cubit and associated State class.

flutter-architect cubit settings --feature profile

Data & Domain Commands #

flutter-architect model <name>

Generates a strongly typed data model with fromJson, toJson, copyWith, and value equality.

flutter-architect model user --feature auth

flutter-architect repository <name>

Generates domain repository interface and data implementation.

flutter-architect repository payment --feature checkout

flutter-architect datasource <name>

Generates remote and local data source implementations.

flutter-architect datasource order --feature checkout

flutter-architect usecase <name>

Generates a single-responsibility callable domain usecase.

flutter-architect usecase calculate_discount --feature checkout

UI Component Commands #

flutter-architect page <name>

Generates a theme-aware Material 3 responsive Scaffold page.

flutter-architect page dashboard

flutter-architect widget <name>

Generates a reusable, theme-aware widget.

flutter-architect widget user_avatar

flutter-architect dialog <name>

Generates a static show() dialog helper with confirm/cancel buttons.

flutter-architect dialog delete_confirmation

flutter-architect bottomsheet <name>

Generates a responsive modal bottom sheet with drag handles and keyboard insets handling.

flutter-architect bottomsheet sort_filter

API Commands #

flutter-architect api <name>

Generates an end-to-end API integration slice with DataSource, ResponseModel, Repository, UseCase, and BLoC:

flutter-architect api login --method post
flutter-architect api fetch_user --method get
flutter-architect api update_profile --method put
flutter-architect api delete_account --method delete

flutter-architect endpoint <name>

Registers a new endpoint constant in lib/core/network/api_endpoints.dart:

flutter-architect endpoint orders --path /v1/user/orders

Utility & Configuration Commands #

flutter-architect theme

Scaffolds or updates Material 3 design tokens, typography, and light/dark theme modes:

flutter-architect theme

flutter-architect localization

Scaffolds Flutter localization (l10n.yaml, lib/l10n/app_en.arb, lib/l10n/app_es.arb):

flutter-architect localization

flutter-architect flavors

Generates multi-flavor build entrypoints (lib/main_development.dart, lib/main_staging.dart, lib/main_production.dart, lib/flavors/flavor_config.dart, and environment files):

flutter-architect flavors

Run a specific flavor:

flutter run -t lib/main_development.dart --flavor development
flutter run -t lib/main_staging.dart --flavor staging
flutter run -t lib/main_production.dart --flavor production

flutter-architect firebase

Generates lib/core/firebase/firebase_service.dart wrapper with Crashlytics, Analytics, and Messaging boilerplate:

flutter-architect firebase

โš™๏ธ Configuration (flutter_architect.yaml) #

When you run flutter-architect init, a flutter_architect.yaml file is placed in your project root:

# Flutter Architect Project Configuration
flutter_architect:
  architecture: clean
  state_management: bloc
  networking: dio
  dependency_injection: get_it
  local_storage: shared_preferences
  theme: material3
  localization: flutter
  environment: dotenv
  generate_entities: false
  # custom_template_path: ./templates

All generator commands inspect this configuration so generated code always matches your project settings.


๐ŸŽจ Custom Templates #

Flutter Architect supports custom template overrides!

  1. Create a .flutter_architect/templates/ folder in your project root (or set custom_template_path in flutter_architect.yaml).
  2. Add your custom template file (e.g. feature_model.dart).
  3. Use variables such as {{feature_name}}, {{feature_pascal}}, {{package_name}}.
  4. When you run flutter-architect feature <name>, your custom template will be used instead of the built-in default!

๐Ÿ›ก๏ธ Safe File Generation & Conflict Resolution #

Flutter Architect guarantees that your existing files are never overwritten silently:

  • Interactive Mode: If a file already exists, the CLI prompts:
    File already exists: lib/features/auth/presentation/pages/auth_page.dart
    ? What would you like to do?:
      > 1) Skip
        2) Overwrite
    
  • Force Overwrite: Pass --force (-f) to overwrite without prompting.
  • Skip Existing: Pass --skip-existing to skip existing files safely.
  • Dry Run: Pass --dry-run to see a preview of all files that would be generated without touching the filesystem.

๐Ÿค– CI/CD Integration #

Add flutter-architect validate into your GitHub Actions workflow (.github/workflows/ci.yml) to enforce Clean Architecture boundaries across all pull requests:

name: Flutter CI

on: [push, pull_request]

jobs:
  validate-and-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Dart & Flutter
        uses: subosito/flutter-action@v2
        with:
          channel: stable

      - name: Install dependencies
        run: flutter pub get

      - name: Install Flutter Architect
        run: dart pub global activate flutter_architect

      - name: Validate Architecture Boundaries
        run: flutter-architect validate

      - name: Analyze Project
        run: flutter analyze

      - name: Run Tests
        run: flutter test

๐Ÿงช Testing #

The package includes comprehensive tests verifying naming utilities, configuration resolution, template rendering, file generation, diagnostics, and CLI integration:

# Run unit & integration tests
dart test

# Run analyzer
dart analyze

# Run formatter
dart format --output=none --set-exit-if-changed .

โ˜• Support #

If Flutter Architect saved you time or helped organize your project, you can buy me a chai:

Buy Me A Chai   Buy Me A Coffee

Phones open a UPI app. Desktops show a QR to scan.


๐Ÿ‘จโ€๐Ÿ’ป Developer #

Kishan Dobariya #


๐Ÿ“„ License #

This package is licensed under the MIT License. See LICENSE for details.

1
likes
160
points
387
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A production-ready Flutter CLI and architecture kit for Clean Architecture, BLoC, API, and project scaffolding.

Repository (GitHub)
View/report issues
Contributing

Topics

#flutter #cli #clean-architecture #bloc #generator

License

MIT (license)

Dependencies

args, meta, path, yaml

More

Packages that depend on flutter_architecture_kit