๐Ÿš€ 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!

Pub Version License: MIT Flutter Author

โœจ 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:

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create your feature branch (git checkout -b feature/amazing-feature)
  3. โœ… Commit your changes (git commit -m 'Add amazing feature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/amazing-feature)
  5. ๐Ÿ”€ 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

๐Ÿ“„ 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


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