Thanks to visit codestin.com
Credit goes to github.com

Skip to content

RahulDev-flutter/blocx_cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

75 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

About

My First CLI Command For Bloc

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •