dev_bloc_cli 0.0.1
dev_bloc_cli: ^0.0.1 copied to clipboard
A command-line interface tool to generate and manage BLoC architecture boilerplate in Flutter and Dart projects.
BLoC CLI #
A powerful and simple command-line interface (CLI) tool for generating and modifying BLoC architecture boilerplate in your Flutter or Dart projects.
Interactive Doc -> https://devesh12335.github.io/bloc_cli #
Why Use BLoC CLI? #
Automate the repetitive parts of setting up BLoCs and focus on your business logic.
- ⚡️ Speed: Quickly generate a complete, working BLoC with a single command.
- ⚖️ Consistency: Ensures all BLoC files follow a consistent folder structure and naming convention.
- ⚙️ Efficiency: Easily add new events, handlers, and state properties without manual file edits.
- 📝 Less Boilerplate: Reduces the amount of manual code you have to write, preventing errors.
🚀 Installation #
Get up and running in three simple steps.
-
Add Dependencies Ensure your
pubspec.yamlfile has the required dependencies.all latest versionsdependencies: args: path: flutter_bloc: bloc: equatable: -
Add CLI to
binDirectory Place themain.dartfile in your project'sbin/folder. Ensure the package name in yourpubspec.yamlmatches what you use in commands (e.g.,bloc_cli). -
Get Dependencies Run the following command in your terminal to download the packages.
dart pub get
📖 Interactive Usage Guide #
Generate a New BLoC #
Creates a new BLoC with view, state, events, and bloc files.
Command:
dart run bloc_cli generate --name <BlocName>
Add a New Handler #
Adds a new event and a corresponding handler function to an existing BLoC.
Command:
dart run bloc_cli add-handler --name <BlocName> --handler <HandlerName>
Add a New State Property #
Adds a new property to the state class. Note: Enclose properties with special characters (like List<Product>) in single quotes in your terminal.
Command:
dart run bloc_cli add-state --name <BlocName> --property '<propertyName>:<DataType>'