🧱 Blocraft CLI
blocraft is a CLI tool to quickly scaffold Flutter projects using Bloc and Clean Architecture. It generates a modular folder structure and injects essential dependencies automatically, including a choice between equatable or freezed for state management.
🔧 Installation
To install blocraft globally, run:
dart pub global activate blocraft
Make sure your Dart pub cache global executables path is added to your system PATH:
$env:PATH += ";$HOME\.pub-cache\bin" # PowerShell (Windows)
# or
export PATH="$PATH":"$HOME/.pub-cache/bin" # Bash (Linux/macOS)
🚀 Usage
Initialize Project Structure & Dependencies
blocraft init
- Creates the core, shared, and features base folders under
lib/src/. - Prompts you to choose between
equatableorfreezedfor state management helper. - Automatically injects dependencies (
bloc,flutter_bloc,go_router,dartz, and your chosen state helper) into yourpubspec.yaml.
Generate a Feature Structure
blocraft feature <feature_name>
- Generates the folder structure for a specific feature (e.g.,
auth).
📦 Dependency Management
When you run blocraft init, the following dependencies will be automatically added to your pubspec.yaml:
Main dependencies
- bloc – State management using the Bloc pattern.
- flutter_bloc – Bloc integration for Flutter apps.
- go_router – Modern routing and navigation for Flutter.
- dartz – Functional programming utilities (e.g., Either, Option, etc).
State management helper (user choice)
- If you choose equatable:
- equatable – Simplifies value equality for Dart objects (default).
- If you choose freezed:
- freezed_annotation – Annotations for freezed models (added to dependencies).
- freezed – Main code generation package (added to dev_dependencies).
- build_runner – Code generation runner (added to dev_dependencies).
All other essential dependencies are injected automatically if not present.
📂 Generated Folder Structure
After running blocraft init:
lib/
└── src/
├── core/
│ ├── error/
│ ├── utils/
│ ├── theme/
│ └── routes/
├── shared/
│ ├── usecases/
│ ├── widgets/
│ └── helpers/
└── features/
After running blocraft feature <feature_name> (e.g., blocraft feature auth):
lib/
└── src/
└── features/
└── auth/
├── data/
│ ├── datasources/
│ ├── models/
│ └── repositories/
├── domain/
│ ├── entities/
│ ├── repositories/
│ └── usecases/
└── presentation/
├── bloc/
└── pages/
📖 About
Created by Singgi — a tool to speed up Flutter clean architecture setup by scaffolding boilerplate folders and managing dependencies automatically.
Libraries
- commands/dependency_manager
- Dependency management utilities for Blocraft CLI.
- commands/feature_command
- commands/init_command
- Provides the entry point for initializing the project structure and dependencies.
- commands/project_structure
- Project structure utilities for Blocraft CLI.
- helpers/state_helper
- State management helper selection for Blocraft CLI.
- utils/file_utils
- File and folder utility functions for Blocraft CLI.