๐Ÿš€ SF CLI - Flutter Scaffolding Tool

pub package Documentation GitHub Stars License Dart Version Build Status

A powerful command-line interface tool for Flutter developers that automates the creation of feature-based project structures, model generation from JSON, and BLoC pattern implementation.

Boost your Flutter development productivity with automated scaffolding and clean architecture patterns.

๐Ÿ“– Documentation โ€ข ๐Ÿš€ Quick Start โ€ข ๐Ÿ’ก Examples โ€ข ๐Ÿค Contributing


โœจ Features

๐Ÿ—๏ธ Project Scaffolding

  • โœ… Complete feature-based architecture setup
  • โœ… Clean folder structure generation
  • โœ… Predefined templates for common patterns
  • โœ… Domain-driven design structure

๐Ÿค– Smart Code Generation

  • โœ… Dart model classes from JSON
  • โœ… Complex nested object support
  • โœ… Null safety and type safety
  • โœ… Automatic serialization methods

๐Ÿงฉ State Management

  • โœ… BLoC/Cubit pattern implementation
  • โœ… Equatable and Freezed support
  • โœ… Best practices enforcement
  • โœ… Immutable state management

โš™๏ธ Developer Tools

  • โœ… Build runner integration
  • โœ… Config-based generation
  • โœ… Enhanced feature creation
  • โœ… Dependency injection setup

๐ŸŽฏ Why Choose SF CLI?

"From idea to implementation in minutes, not hours"

  • ๐Ÿš€ Rapid Development: Generate complete features with a single command
  • ๐Ÿ“ Clean Architecture: Enforces best practices and maintainable code structure
  • ๐Ÿ”ง Type Safety: Full null safety and strong typing support
  • ๐ŸŽจ Customizable: Flexible configuration options for different project needs
  • ๐Ÿ“š Well Documented: Comprehensive documentation with examples
  • ๐Ÿงช Battle Tested: Used in production Flutter applications

๐Ÿ“ฆ Installation

dart pub global activate sf_cli

Local Installation

Add to your pubspec.yaml:

dev_dependencies:
  sf_cli: ^1.0.0

Then run:

dart pub get

Verify Installation

sf_cli --version

๐Ÿš€ Quick Start

Get up and running with SF CLI in under 2 minutes:

# 1. Install SF CLI globally
dart pub global activate sf_cli

# 2. Initialize your Flutter project structure
sf_cli init

# 3. Generate your first feature
sf_cli features --name user_profile --freezed

# 4. Generate models from JSON
sf_cli model --file path/to/user.json

# 5. Run build runner to generate code
sf_cli runner

๐Ÿ“‹ Usage

Initialize a New Flutter Project Structure

sf_cli init

This creates a comprehensive folder structure including:

  • Feature-based architecture (auth, splash)
  • Shared components (API, constants, themes, utils)
  • Clean architecture layers (domain, logic, screens, widgets)

Generate a New Feature

sf_cli features --name user_profile
# or
sf_cli features -n user_profile

# Generate with Freezed cubit and state
sf_cli features --name user_profile --freezed

Creates a complete feature structure:

lib/features/user_profile/
โ”œโ”€โ”€ domain/
โ”‚   โ”œโ”€โ”€ models/user_profile_model.dart
โ”‚   โ”œโ”€โ”€ repository/user_profile_repository.dart
โ”‚   โ””โ”€โ”€ services/user_profile_service.dart
โ”œโ”€โ”€ logic/user_profile/
โ”‚   โ”œโ”€โ”€ user_profile_cubit.dart
โ”‚   โ””โ”€โ”€ user_profile_state.dart
โ”œโ”€โ”€ screens/user_profile_screen.dart
โ”œโ”€โ”€ widgets/user_profile_widget.dart
โ””โ”€โ”€ user_profile_config.json

Generate Model Classes from JSON

sf_cli model --file path/to/your/model.json
# or
sf_cli model -f path/to/your/model.json

Example JSON input:

{
  "id": 1,
  "name": "John Doe",
  "email": "john@example.com",
  "profile": {
    "age": 30,
    "preferences": ["coding", "reading"]
  }
}

Generates a Dart model class with:

  • Proper constructors
  • JSON serialization methods
  • Null safety support
  • Nested class handling

Generate BLoC Cubit

sf_cli cubit --name authentication
# or
sf_cli cubit -n authentication

# Generate with Freezed
sf_cli cubit --name authentication --freezed

Creates cubit and state files with proper BLoC patterns. Use --freezed flag to generate freezed variants with immutable state classes.

Generate BLoC

sf_cli bloc --name authentication
# or
sf_cli bloc -n authentication

# Generate with Freezed
sf_cli bloc --name authentication --freezed

Creates bloc, event, and state files with proper BLoC patterns. Use --freezed flag to generate freezed variants with immutable event and state classes.

Run Build Runner

sf_cli runner

Executes: dart run build_runner build --delete-conflicting-outputs

Generate from Configuration File

sf_cli config --config-file path/to/config.json
# or
sf_cli config -c path/to/config.json

Example configuration:

{
  "user_model": {
    "model_class_relative_path": "lib/features/user/domain/models/user.json",
    "end_point": "/api/users",
    "method": "get",
    "function_name": "getUsers",
    "parameters": {
      "page": "int",
      "limit": "int"
    }
  }
}

Generate Complete Feature from Enhanced Configuration

# Generate complete feature with freezed models and state management (recommended)
sf_cli generate-feature --config path/to/enhanced_config.json --freezed

# Generate feature with regular models and state management
sf_cli generate-feature --config path/to/enhanced_config.json
# or
sf_cli generate-feature -c path/to/enhanced_config.json --freezed

This new command generates a complete feature structure including:

  • Freezed models with JSON serialization
  • Repository and service layers with dependency injection
  • Cubit-based state management
  • UI screens and widgets
  • Proper error handling and loading states

See example/ENHANCED_FEATURE_GENERATION.md for detailed documentation and example/enhanced_feature_config.json for a complete example.

๐Ÿ“Š Command Reference

Command Description Options
init Initialize project structure None
features Generate feature scaffold --name, -n: Feature name
--freezed: Use Freezed for cubit/state
model Generate model from JSON --file, -f: JSON file path
cubit Generate BLoC cubit --name, -n: Cubit name
--freezed: Use Freezed for cubit/state
bloc Generate BLoC bloc --name, -n: Bloc name
--freezed: Use Freezed for bloc/event/state
runner Run build_runner None
config Generate from config --config-file, -c: Config file path
generate-feature Generate complete feature from enhanced config --config, -c: Enhanced config file path
--freezed: Use Freezed for models/state

๐Ÿ’ก Examples

๐Ÿ—๏ธ Complete Project Setup
# Initialize a new Flutter project with SF CLI structure
flutter create my_app
cd my_app
sf_cli init

# Generate authentication feature with Freezed
sf_cli features --name auth --freezed

# Generate user profile feature
sf_cli features --name user_profile --freezed

# Generate models from API responses
sf_cli model --file api_responses/user.json
sf_cli model --file api_responses/auth.json

# Run build runner to generate code
sf_cli runner
๐Ÿค– Model Generation from Complex JSON

Given a complex JSON structure:

{
  "user": {
    "id": 1,
    "profile": {
      "name": "John Doe",
      "avatar": "https://example.com/avatar.jpg",
      "settings": {
        "theme": "dark",
        "notifications": true,
        "preferences": ["coding", "reading"]
      }
    },
    "posts": [
      {
        "id": 1,
        "title": "My First Post",
        "tags": ["flutter", "dart"]
      }
    ]
  }
}

Generate with:

sf_cli model --file user_data.json

This creates properly nested Dart classes with full type safety.

๐Ÿงฉ State Management Setup
# Generate authentication cubit with Freezed
sf_cli cubit --name auth --freezed

# Generate user management bloc with Freezed
sf_cli bloc --name user_management --freezed

# The generated files include:
# - Immutable state classes
# - Proper event handling
# - Type-safe state transitions
# - Built-in equality comparisons

๐Ÿ›๏ธ Architecture Patterns

This tool promotes clean architecture patterns:

  • Domain Layer: Models, repositories, and business logic
  • Logic Layer: BLoC/Cubit state management
  • Presentation Layer: Screens and widgets
  • Shared Components: Reusable utilities and constants

๐Ÿ“‹ Requirements

  • Dart SDK: ^3.4.3
  • Flutter: Compatible with latest stable versions
  • Operating System: Windows, macOS, Linux

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some 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/naveenld024/sf_cli.git
cd sf_cli

# Install dependencies
dart pub get

# Run tests
dart test

# Build the project
dart compile exe bin/sf_cli.dart

Code Style

  • Follow Dart style guide
  • Use meaningful commit messages
  • Add tests for new features
  • Update documentation as needed

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ“– Documentation

๐Ÿ“– Complete Documentation - Comprehensive guides, examples, and API reference

๐Ÿ†˜ Support

๐ŸŒŸ Show Your Support

If this project helped you, please consider:

  • โญ Starring the repository
  • ๐Ÿ› Reporting bugs and issues
  • ๐Ÿ’ก Suggesting new features
  • ๐Ÿ“– Contributing to documentation
  • ๐Ÿ”„ Sharing with other Flutter developers

Made with โค๏ธ by Naveen

Happy Flutter Development! ๐Ÿš€