blocy 1.0.10
blocy: ^1.0.10 copied to clipboard
CLI tool to create Flutter apps with BLoC and clean architecture.
BlocY CLI #
Build Flutter apps faster with a CLI tool that applies BLoC and clean architecture for scalable, maintainable projects.
Features #
- π Rapidly initialize new or existing Flutter projects with BLoC architecture
- π Create consistent folder structure following clean architecture principles
- β¨ Generate feature modules with all necessary components
- π§© Automatically set up routing configuration using go_router
- π οΈ Add all required dependencies
Installation #
dart pub global activate blocy
Commands #
Initialize a project #
Convert an existing Flutter project to use BLoC architecture with a clean, organized structure:
blocy init
Options:
--project-dir, -p: Path to the Flutter project (default: current directory)
Create a new feature #
Generate a new feature with all necessary layers (presentation, domain, data):
blocy feature <feature_name>
Options:
--project-dir, -p: Path to the Flutter project (default: current directory)
Folder Structure #
The tool creates the following structure for your Flutter project:
lib/
βββ core/
β βββ constants/
β βββ dependency_injection/
β βββ error/
β βββ network/
β βββ themes/
β βββ utils/
βββ features/
β βββ home/ # Default feature
β βββ data/
β β βββ datasources/
β β βββ models/
β β βββ repositories/
β βββ domain/
β β βββ entities/
β β βββ repositories/
β β βββ usecases/
β βββ presentation/
β βββ bloc/
β βββ pages/
β βββ widgets/
βββ routes/
βββ services/
βββ widgets/
Each feature follows Clean Architecture principles with separate layers:
- Presentation Layer: UI components, BLoC classes, pages, and widgets
- Domain Layer: Business logic, entities, interfaces for repositories, and use cases
- Data Layer: Data sources, models and repository implementations
Generated Files For Each Feature #
When you create a new feature, BlocY generates:
Presentation Layer #
- BLoC, Event, and State files
- Feature page with basic UI
Domain Layer #
- Entity class
- Repository interface
- Use case implementation
Data Layer #
- API data source (with implementation)
- Data model with JSON serialization
- Repository implementation
Dependencies #
BlocY CLI automatically adds these dependencies to your project:
bloc: ^8.1.2flutter_bloc: ^8.1.3go_router: ^10.1.2dartz: ^0.10.1get_it: ^7.6.0equatable: ^2.0.5
Example Usage #
Initialize a project and create a feature #
# Initialize the project in the current directory
blocy init
# Create a new feature called "authentication"
blocy feature authentication
Working with the generated code #
After creating a feature, you'll have a fully functional architecture to work with:
- Add your business logic to the use cases
- Implement the data sources with actual API calls
- Update the UI in the pages and widgets
- Add events and states to the BLoC classes
- Update the DI container to register your dependencies
Contributing #
Contributions, issues, and feature requests are welcome! Feel free to check issues page.
License #
This project is MIT licensed.