๐ SF CLI - Flutter Scaffolding Tool
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
๐ค Smart Code Generation
|
๐งฉ State Management
โ๏ธ Developer Tools
|
๐ฏ 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
Global Installation (Recommended)
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:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some 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/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
Quick Links
๐ Support
- ๐ Documentation
- ๐ Issue Tracker
- ๐ฌ Discussions
- ๐ง Email 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! ๐
Libraries
- bloc
- build_runners
- cubit
- feature
- generate_feature_from_config
- generate_from_config
- generate_model
- init
- pub
- sf_cli
- SF CLI - Flutter Scaffolding Tool