bclean 0.1.0
bclean: ^0.1.0 copied to clipboard
A powerful CLI tool for Flutter to generate Clean Architecture with BLoC or Cubit state management and dartz error handling, inspired by get_cli.
bclean #
A fast, get_cli-inspired CLI tool for Flutter & Dart to scaffold Clean Architecture projects with BLoC / Cubit state management and dartz (Either<Failure, T>) functional error handling.
Installation (Local Development) #
Activate globally from this directory:
dart pub global activate --source path .
Commands & Usage #
1. Initialize Clean Architecture Core (bclean init) #
Generates:
lib/core/error/failures.dart&exceptions.dartlib/core/usecases/usecase.dart(withdartzEither<Failure, Type>)lib/core/network/network_info.dartlib/core/router/app_router.dartlib/injection_container.dart(get_it)- Automatically adds
flutter_bloc,equatable,dartz, andget_ittopubspec.yaml.
bclean init
2. Create a Full Feature (bclean create feature:<name>) #
Generates Entity, Repository Interface, UseCase, Model, Remote & Local DataSources, Repository Implementation, BLoC (Event + State) or Cubit, Page, and auto-registers everything in injection_container.dart and app_router.dart:
bclean create feature:auth
Options:
- Use Cubit instead of BLoC:
bclean create feature:profile --cubit - Skip
LocalDataSource:bclean create feature:orders --no-local
3. Create Sub-Components inside an Existing Feature #
- UseCase (Also auto-adds method to Domain
Repository, DataRepositoryImpl, andinjection_container.dart!):bclean create usecase:login on auth - BLoC / Cubit:
bclean create bloc:session on auth bclean create cubit:theme on settings - Page (Also auto-registers route in
app_router.dart):bclean create page:register on auth
4. Generate Domain Entity & Data Model from JSON (bclean generate model) #
Parses any JSON file (including nested objects and arrays) and generates both the Domain Entity (Equatable) and Data Model (fromJson, toJson, copyWith):
bclean generate model on auth with assets/models/user_profile.json
Options:
- Custom model name:
--name custom_user - Generate only Data Model without Domain Entity:
--skip-entity
5. Optional Project Configuration in pubspec.yaml #
You can configure project-wide defaults in your Flutter project's pubspec.yaml:
bclean:
state_management: bloc # or cubit
include_local: true