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!
- π― 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
- β 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
- ποΈ 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
Global Installation (Recommended):
dart pub global activate rj_blocxAdd 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 ~/.bashrcVerify Installation:
rj_blocx --version
# Should output: RJ BlocX CLI version 1.0.0 - Created by Rahul Verma# 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, PermissionsWhat 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
rj_blocx create <project_name>Example:
rj_blocx create my_shopping_appInteractive 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
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_pickerMultiple Packages (Interactive):
rj_blocx add packagesPackage 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 Module:
rj_blocx generate module <module_name>Example:
rj_blocx generate module user_profileGenerates:
- π 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 screenExamples:
rj_blocx generate screen product_details
rj_blocx generate page checkout_formScreen 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
- β 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
- β Welcome Screen with user information
- β Quick Actions grid layout
- β Navigation to other modules
- β Profile Management integration
- β Settings access
- β 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
- β 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
- β 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
# 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# 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)# Analyze code
flutter analyze
# Run tests
flutter test
# Format code
dart format .
# Generate coverage
flutter test --coverageRJ BlocX CLI follows Clean Architecture principles:
- Screens: UI components and user interactions
- BLoC: State management and business logic
- Widgets: Reusable UI components
- Models: Data entities and business objects
- Repositories: Abstract data contracts
- Use Cases: Business logic operations
- Repositories: Concrete data implementations
- Data Sources: API clients and local storage
- Models: Data transfer objects
- Network: HTTP clients and API services
- Utils: Helper functions and utilities
- Constants: App-wide constants and configuration
- Errors: Error handling and exceptions
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';
}Modify lib/core/theme/app_theme.dart:
static ThemeData lightTheme = ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue, // Your brand color
),
// Customize other theme properties
);Add routes in lib/app/app_router.dart:
case AppConstants.productListRoute:
return MaterialPageRoute(builder: (_)
=>
const
ProductListScreen
(
)
);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 ~/.zshrcFlutter not found:
# Verify Flutter installation
flutter doctor
# Install if needed: https://flutter.dev/docs/get-started/installPermission denied:
# Fix executable permissions
chmod +x ~/.pub-cache/bin/rj_blocxProject creation fails:
# Ensure you have write permissions
# Run in a directory you own
cd ~/Projects
rj_blocx create my_appWe 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
# 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 .Rahul Verma - Flutter Developer & Tech Enthusiast
- π GitHub: @RahulDev-flutter
- πΌ LinkedIn: Rahul Verma
- π§ Email: [email protected]
- π Portfolio: rahulverma.dev
This project is licensed under the MIT License - see the LICENSE file for details.
- Flutter Team for the amazing framework
- BLoC Library for excellent state management
- Community for feedback and contributions
- π 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! π