๐ RJ BlocX CLI - Enhanced Flutter Project Generator
Created with โค๏ธ by Rahul Verma
A powerful command-line tool for creating Flutter applications with BLoC architecture, clean code structure, and industry best practices. Generate production-ready Flutter projects in seconds!
โจ Features
๐๏ธ Project Generation
- ๐ฏ Interactive Setup - Choose API client, modules, and packages
- ๐๏ธ Clean Architecture - Proper separation of concerns
- ๐ BLoC State Management - Complete BLoC pattern implementation
- ๐ Secure Storage - Encrypted token storage with session management
- ๐ Network Layer - Dio/HTTP with comprehensive error handling
- ๐งช Testing Ready - Pre-configured testing infrastructure
๐ฆ Package Management
- โ Smart Package Addition - Interactive package selection with descriptions
- ๐ท๏ธ Categorized Packages - Organized by functionality (State Management, UI, etc.)
- ๐ก Usage Hints - Helpful import statements and usage tips
- ๐ Popular Packages - Curated list of most-used Flutter packages
๐จ Dynamic Generation
- ๐๏ธ Module Generation - Complete modules with BLoC, Repository, and Models
- ๐ฑ Screen Templates - List, Detail, Form, and Basic screen types
- ๐ Auto-Registration - Automatic service locator and routing updates
- ๐ CamelCase Support - Proper naming conventions throughout
๐ Quick Start
Installation
Global Installation (Recommended):
dart pub global activate rj_blocx
Add to PATH: (if not already added)
# For macOS/Linux (Zsh)
echo 'export PATH="$PATH":"$HOME/.pub-cache/bin"' >> ~/.zshrc
source ~/.zshrc
# For macOS/Linux (Bash)
echo 'export PATH="$PATH":"$HOME/.pub-cache/bin"' >> ~/.bashrc
source ~/.bashrc
Verify Installation:
rj_blocx --version
# Should output: RJ BlocX CLI version 1.0.0 - Created by Rahul Verma
Create Your First Project
# Create a new Flutter project
rj_blocx create my_awesome_app
# Follow the interactive prompts:
# ๐ API Client: Dio (recommended) or HTTP
# ๐ฆ Additional Modules: Profile, Settings
# ๐ง Extra Packages: Hive, ImagePicker, Permissions
What gets generated:
my_awesome_app/
โโโ lib/
โ โโโ app/ # App configuration
โ โ โโโ app_router.dart # Navigation routing
โ โ โโโ service_locator.dart # Dependency injection
โ โ โโโ bloc_observer.dart # BLoC debugging
โ โโโ core/ # Core functionality
โ โ โโโ network/ # API client & services
โ โ โโโ constants/ # App & API constants
โ โ โโโ utils/ # Utilities & helpers
โ โ โโโ errors/ # Error handling
โ โโโ modules/ # Feature modules
โ โ โโโ auth/ # Authentication
โ โ โ โโโ bloc/ # State management
โ โ โ โโโ screens/ # Login/Register screens
โ โ โ โโโ models/ # User models
โ โ โ โโโ repository/ # Auth repository
โ โ โโโ home/ # Home dashboard
โ โ โโโ bloc/ # Home state management
โ โ โโโ screens/ # Home/Profile screens
โ โ โโโ repository/ # Home repository
โ โโโ main.dart # App entry point
โโโ analysis_options.yaml # Linting rules
โโโ README.md # Project documentation
๐ Commands
๐ Create Project
rj_blocx create <project_name>
Example:
rj_blocx create my_shopping_app
Interactive Features:
- ๐ API Client Selection: Choose between Dio (advanced) or HTTP (simple)
- ๐ฆ Module Selection: Add Profile, Settings, or other modules
- ๐ง Package Selection: Add commonly used packages like Hive, ImagePicker
- ๐ Configuration Summary: Review your choices before generation
๐ฆ Add Packages
Single Package:
rj_blocx add package <package_name>
Examples:
rj_blocx add package shared_preferences
rj_blocx add package cached_network_image
rj_blocx add package image_picker
Multiple Packages (Interactive):
rj_blocx add packages
Package Categories:
- ๐ State Management: flutter_bloc, provider, riverpod
- ๐ Networking: dio, http, retrofit
- ๐พ Storage: shared_preferences, hive, sqflite
- ๐จ UI Components: cached_network_image, lottie, shimmer
- ๐งญ Navigation: go_router, auto_route
- ๐ Forms: flutter_form_builder, form_builder_validators
- ๐ฑ Device: image_picker, camera, geolocator, permission_handler
- ๐ ๏ธ Utils: intl, url_launcher, path_provider
๐จ Generate Components
Generate Module:
rj_blocx generate module <module_name>
Example:
rj_blocx generate module user_profile
Generates:
- ๐ Complete module structure
- ๐ BLoC files (bloc, event, state)
- ๐ฑ Customizable screens
- ๐พ Repository with API integration
- ๐ Data models
- ๐ง Auto-registration in service locator
Generate Screen:
rj_blocx generate screen <screen_name>
rj_blocx generate page <page_name> # Alias for screen
Examples:
rj_blocx generate screen product_details
rj_blocx generate page checkout_form
Screen Types:
- ๐ List Screen: Displays items with search, filter, and CRUD operations
- ๐ Detail Screen: Shows detailed item information with edit/delete options
- ๐ Form Screen: Input forms with validation and submission
- ๐ฑ Basic Screen: Simple content screen with customizable layout
๐ฏ Generated Features
๐ Authentication System
- โ Secure Login/Register with input validation
- โ Token Management with automatic refresh
- โ Session Persistence with encrypted storage
- โ Biometric Authentication support (optional)
- โ Password Reset flow
- โ Logout with complete cleanup
๐ Home Dashboard
- โ Welcome Screen with user information
- โ Quick Actions grid layout
- โ Navigation to other modules
- โ Profile Management integration
- โ Settings access
๐ Network Layer
- โ HTTP/Dio Client with interceptors
- โ Error Handling with user-friendly messages
- โ Request/Response Logging for debugging
- โ Token Injection for authenticated requests
- โ Retry Logic for failed requests
- โ Timeout Configuration with fallbacks
๐พ Data Layer
- โ Repository Pattern for data abstraction
- โ Either Pattern for error handling
- โ Model Classes with JSON serialization
- โ Caching Strategy (if Hive selected)
- โ Local Storage with flutter_secure_storage
๐จ UI Components
- โ Material Design 3 components
- โ Responsive Layouts for different screen sizes
- โ Loading States with shimmer effects
- โ Error States with retry options
- โ Empty States with helpful messages
- โ Form Validation with real-time feedback
๐ ๏ธ Development Workflow
Initial Setup
# 1. Create project
rj_blocx create my_app
# 2. Navigate to project
cd my_app
# 3. Install dependencies
flutter pub get
# 4. Run the app
flutter run
Adding New Features
# 1. Generate new module
rj_blocx generate module products
# 2. Add required packages
rj_blocx add package sqflite
rj_blocx add packages # Interactive selection
# 3. Generate specific screens
rj_blocx generate screen product_list
rj_blocx generate screen product_detail
# 4. Update API constants and routing
# (Follow the generated comments in code)
Code Quality
# Analyze code
flutter analyze
# Run tests
flutter test
# Format code
dart format .
# Generate coverage
flutter test --coverage
๐๏ธ Architecture Overview
RJ BlocX CLI follows Clean Architecture principles:
๐ฑ Presentation Layer
- Screens: UI components and user interactions
- BLoC: State management and business logic
- Widgets: Reusable UI components
๐ผ Domain Layer
- Models: Data entities and business objects
- Repositories: Abstract data contracts
- Use Cases: Business logic operations
๐พ Data Layer
- Repositories: Concrete data implementations
- Data Sources: API clients and local storage
- Models: Data transfer objects
๐ง Core Layer
- Network: HTTP clients and API services
- Utils: Helper functions and utilities
- Constants: App-wide constants and configuration
- Errors: Error handling and exceptions
๐จ Customization
๐ฏ API Configuration
Update lib/core/constants/api_constants.dart:
class ApiConstants {
static const String baseUrl = 'https://your-api.com';
static const String apiVersion = '/v1';
// Add your endpoints
static const String products = '/products';
static const String orders = '/orders';
}
๐จ Theme Configuration
Modify lib/core/theme/app_theme.dart:
static ThemeData lightTheme = ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue, // Your brand color
),
// Customize other theme properties
);
๐งญ Navigation
Add routes in lib/app/app_router.dart:
case AppConstants.productListRoute:
return MaterialPageRoute(builder: (_)
=>
const
ProductListScreen
(
)
);
๐ Troubleshooting
Common Issues
Command not found:
# Ensure PATH is set correctly
echo $PATH | grep pub-cache
# If not found, add to your shell config
echo 'export PATH="$PATH":"$HOME/.pub-cache/bin"' >> ~/.zshrc
source ~/.zshrc
Flutter not found:
# Verify Flutter installation
flutter doctor
# Install if needed: https://flutter.dev/docs/get-started/install
Permission denied:
# Fix executable permissions
chmod +x ~/.pub-cache/bin/rj_blocx
Project creation fails:
# Ensure you have write permissions
# Run in a directory you own
cd ~/Projects
rj_blocx create my_app
๐ค Contributing
We welcome contributions! Here's how to help:
- ๐ด Fork the repository
- ๐ฟ Create your feature branch (
git checkout -b feature/amazing-feature) - โ
Commit your changes (
git commit -m 'Add amazing feature') - ๐ค Push to the branch (
git push origin feature/amazing-feature) - ๐ Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/RahulDev-flutter/blocx_cli.git
cd blocx_cli
# Install dependencies
dart pub get
# Run tests
dart test
# Test locally
dart pub global activate --source path .
๐จโ๐ป About the Author
Rahul Verma - Flutter Developer & Tech Enthusiast
- ๐ GitHub: @RahulDev-flutter
- ๐ผ LinkedIn: Rahul Verma
- ๐ง Email: [email protected]
- ๐ Portfolio: rahulverma.dev
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Flutter Team for the amazing framework
- BLoC Library for excellent state management
- Community for feedback and contributions
๐ Support
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ง Email: [email protected]
Made with โค๏ธ by Rahul Verma for the Flutter community
Transform your Flutter development workflow with RJ BlocX CLI! ๐
Libraries
- rj_blocx
- RJ BlocX CLI - Enhanced Flutter Project Generator