Save Points Flutter Template Builder

A powerful CLI tool to generate Flutter projects with custom folder structure, themes, core files, and code generation capabilities.

Screenshots

Example App Screenshot 1

Example App Screenshot 2


💡 Coming Soon: بلاش إندهاش لسه التقيل مجاش 🚀
More exciting features and improvements are on the way! Stay tuned for updates.

Features

  • 🚀 Generates Flutter projects with a clean, organized structure
  • 🎨 Pre-configured themes (light & dark mode) with easy localization
  • 📁 Custom folder structure (core/, models/, states/, blocs/, notifiers/, repositories/, etc.)
  • 📝 Pre-built core files (app_theme.dart, app_colors.dart, routes.dart, etc.)
  • 🔧 Code Generation: Generate models, states, blocs, notifiers, and repositories
  • 📦 Android Production Ready: Automated keystore generation and signing configuration
  • 🎯 State Management: Support for Bloc and Riverpod patterns
  • 🔄 JSON Serialization: Auto-generated toJson/fromJson with Equatable
  • 🌍 Localization: Built-in support for easy_localization with Arabic and English
  • 📚 Reusable Widgets: 20+ pre-built common widgets
  • 🛠️ Utilities: Extensions, helpers, validators, and date formatters
  • 🔍 Dry-run mode for previewing changes
  • 📊 Progress indicators for long operations
  • 🔐 Security policy and responsible disclosure
  • 📚 Comprehensive documentation and contribution guidelines

Installation

Local Development

  1. Clone this repository

  2. Install dependencies:

    dart pub get
    
  3. Run the CLI:

    dart run bin/save_points_flutter_template_builder.dart create my_app
    

Global Installation (After Publishing)

Once published to pub.dev, you can install it globally:

dart pub global activate save_points_flutter_template_builder

Then use it from anywhere:

save_points_flutter_template_builder create my_app

Usage

Create Project

# Create a new Flutter project
dart run save_points_flutter_template_builder:create my_app

# Or if installed globally
save_points_flutter_template_builder create my_app

# Interactive mode (prompts for project name and namespace)
save_points_flutter_template_builder create --interactive

# Create with Android production setup
save_points_flutter_template_builder create my_app --android-production

# Dry run mode (preview changes without creating files)
save_points_flutter_template_builder create my_app --dry-run

# Overwrite existing directory
save_points_flutter_template_builder create my_app --force

# Use custom config file
save_points_flutter_template_builder create my_app --config ./builder.yaml

Generate Code

# Generate model class with JSON serialization
save_points_flutter_template_builder model User --interactive
save_points_flutter_template_builder model Product --fields "id:int:false,name:String:false,price:double:false"

# Generate state class for state management
save_points_flutter_template_builder state AuthState --interactive
save_points_flutter_template_builder state ProductState --fields "data:Product?:true,error:String?:true" --include-states "initial,loading,success,error"

# Generate Riverpod notifier
save_points_flutter_template_builder notifier AuthNotifier --interactive
save_points_flutter_template_builder notifier ProductNotifier --state ProductState

# Generate Bloc with events
save_points_flutter_template_builder bloc AuthBloc --interactive
save_points_flutter_template_builder bloc ProductBloc --state ProductState --events "Load,Refresh,Error"

# Generate repository for data access
save_points_flutter_template_builder repository UserRepository --interactive
save_points_flutter_template_builder repository ProductRepository --model Product --methods "getAll,getById,create,update,delete"

Android Production Setup

# Prepare Android for production (interactive mode)
save_points_flutter_template_builder prepare-android --interactive

# Prepare Android for production (non-interactive, uses defaults)
save_points_flutter_template_builder prepare-android

# Prepare Android for production in specific project
save_points_flutter_template_builder prepare-android --path /path/to/project

Other Commands

# Check version
save_points_flutter_template_builder --version

# Show help
save_points_flutter_template_builder --help
save_points_flutter_template_builder <command> --help

Generated Project Structure

my_app/
├── lib/
│   ├── core/
│   │   ├── constants/
│   │   │   ├── app_constants.dart
│   │   │   └── app_strings.dart
│   │   ├── config/
│   │   │   └── app_config.dart
│   │   ├── network/
│   │   │   ├── api_consumer.dart
│   │   │   ├── dio_api_consumer.dart
│   │   │   └── http_api_consumer.dart
│   │   ├── services/
│   │   │   └── example_service.dart
│   │   ├── style/
│   │   │   ├── app_theme.dart
│   │   │   ├── app_colors.dart
│   │   │   ├── app_text_styles.dart
│   │   │   ├── app_light_theme.dart
│   │   │   └── app_dark_theme.dart
│   │   ├── utils/
│   │   │   ├── validators.dart
│   │   │   ├── extensions.dart
│   │   │   ├── helpers.dart
│   │   │   ├── date_formatter.dart
│   │   │   ├── error_handler.dart
│   │   │   └── logger_service.dart
│   │   └── widgets/
│   │       ├── app_button.dart
│   │       ├── app_card.dart
│   │       ├── app_dialog.dart
│   │       ├── app_text_field.dart
│   │       └── ... (20+ reusable widgets)
│   ├── models/          # Generated model classes
│   ├── states/          # Generated state classes
│   ├── blocs/           # Generated bloc classes
│   ├── notifiers/       # Generated notifier classes
│   ├── repositories/    # Generated repository classes
│   ├── screens/
│   │   ├── home/
│   │   ├── login/
│   │   ├── register/
│   │   └── ...
│   ├── routes/
│   │   ├── app_routes.dart
│   │   └── route_generator.dart
│   └── main.dart
├── assets/
│   ├── translations/
│   │   ├── en.json
│   │   └── ar.json
│   └── icons/
└── android/
    ├── keystore.properties  # (if Android production setup)
    └── app/
        └── proguard-rules.pro

Generated Files

Core Files

  • app_constants.dart: Application-wide constants (API URLs, timeouts, etc.)
  • app_strings.dart: String constants for the app
  • app_colors.dart: Color palette for the app
  • app_theme.dart: Light and dark theme configurations
  • app_config.dart: Environment-based configuration
  • app_routes.dart: Route name constants
  • route_generator.dart: Route generation logic

Utilities

  • validators.dart: Form validation utilities (email, phone, password, etc.)
  • extensions.dart: Extension methods for BuildContext, String, DateTime, List, etc.
  • helpers.dart: Helper functions (formatting, clipboard, keyboard, device detection)
  • date_formatter.dart: Date formatting utilities
  • error_handler.dart: Error handling utilities
  • logger_service.dart: Logging service

Widgets

20+ reusable widgets including:

  • app_button.dart: Custom button widget
  • app_card.dart: Card widget
  • app_dialog.dart: Dialog widget
  • app_text_field.dart: Text field with validation
  • app_snackbar.dart: Snackbar widget
  • app_avatar.dart: Avatar widget
  • app_badge.dart: Badge widget
  • And many more...

Code Generation

Models

  • Generates model classes with toJson() and fromJson() methods
  • Includes copyWith() method for immutable updates
  • Uses Equatable for value equality
  • Supports all common types (String, int, double, bool, DateTime, List, Map)

States

  • Generates state classes extending Equatable
  • Factory constructors for different state types (initial, loading, success, error)
  • copyWith() method for state updates

Notifiers (Riverpod)

  • Generates StateNotifier classes
  • Creates StateNotifierProvider
  • Common state management methods (reset, setLoading, setSuccess, setError)

Blocs

  • Generates Bloc classes with event handling
  • Creates event classes extending Equatable
  • Event handlers with TODO comments for implementation

Repositories

  • Generates repository classes with CRUD methods
  • Uses ApiConsumer for API communication
  • Error handling and model serialization
  • Configurable base path for API endpoints

Main.dart

The generated main.dart includes:

  • MaterialApp with theme configuration
  • Route generation setup
  • Localization setup with easy_localization
  • Proper app structure

Dependencies

The generated projects include these dependencies:

  • http: ^1.2.2 - HTTP client
  • dio: ^5.5.0 - Powerful HTTP client
  • flutter_dotenv: ^6.0.0 - Environment variables
  • package_info_plus: ^9.0.0 - Package information
  • flutter_secure_storage: ^9.2.2 - Secure storage
  • easy_localization: ^3.0.8 - Localization
  • save_points_intl: ^1.0.1 - Internationalization
  • equatable: ^2.0.5 - Value equality
  • flutter_riverpod: ^3.0.3 - State management (Riverpod)
  • flutter_bloc: ^9.1.1 - State management (Bloc)

Customization

To customize the generated templates, edit the files in:

  • lib/src/templates/templates/ - Template content files

Each template is a separate Dart file with a static content getter, making it easy to maintain and refactor.

Customizing Generated Code

All code generation commands support interactive mode where you can:

  • Specify field names and types
  • Choose which methods to include
  • Configure state types and events
  • Customize file locations

Development

Project Structure

lib/
├── src/
│   ├── commands/          # CLI commands
│   │   ├── create_command.dart
│   │   ├── model_command.dart
│   │   ├── state_command.dart
│   │   ├── notifier_command.dart
│   │   ├── bloc_command.dart
│   │   ├── repository_command.dart
│   │   └── prepare_android_command.dart
│   ├── generator/         # Project generation logic
│   │   ├── android/       # Android production helpers
│   │   │   ├── keystore_manager.dart
│   │   │   ├── build_gradle_configurator.dart
│   │   │   ├── proguard_configurator.dart
│   │   │   └── gradle_properties_configurator.dart
│   │   └── templates/     # Code generation templates
│   ├── templates/         # Template files
│   │   ├── templates/     # Individual template content
│   │   └── assets/        # Asset templates (translations, icons)
│   └── utils/             # Utility classes
└── bin/
    └── save_points_flutter_builder.dart  # CLI entry point

Adding New Templates

  1. Create a new template file in lib/src/templates/templates/
  2. Add a class with a static content getter
  3. Register it in template_loader.dart
  4. Add the generation logic in template_processor.dart

Adding New Code Generators

  1. Create a new command in lib/src/commands/
  2. Create a template generator in lib/src/generator/templates/
  3. Register the command in bin/save_points_flutter_builder.dart
  4. Add the command to the commands barrel file

Quick Examples

Complete Workflow Example

# 1. Create a new Flutter project with Android production setup
save_points_flutter_template_builder create my_ecommerce_app --android-production --interactive

# 2. Generate a Product model
save_points_flutter_template_builder model Product --fields "id:int:false,name:String:false,price:double:false,description:String?:true"

# 3. Generate a ProductState
save_points_flutter_template_builder state ProductState --fields "products:List<Product>?:true,error:String?:true,isLoading:bool:false" --include-states "initial,loading,success,error"

# 4. Generate a ProductBloc
save_points_flutter_template_builder bloc ProductBloc --state ProductState --events "LoadProducts,RefreshProducts,Error"

# 5. Generate a ProductRepository
save_points_flutter_template_builder repository ProductRepository --model Product --methods "getAll,getById,create,update,delete"

State Management Setup Example

# For Riverpod
save_points_flutter_template_builder state AuthState --interactive
save_points_flutter_template_builder notifier AuthNotifier --state AuthState

# For Bloc
save_points_flutter_template_builder state AuthState --interactive
save_points_flutter_template_builder bloc AuthBloc --state AuthState --events "Login,Logout,CheckAuth"

Testing

Run the test suite:

# Run all tests
dart test

# Run tests with coverage
dart test --coverage=coverage

# Generate coverage report
dart pub global activate coverage
dart pub global run coverage:format_coverage \
  --lcov \
  --in=coverage \
  --out=coverage/lcov.info \
  --packages=.dart_tool/package_config.json \
  --report-on=lib

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Security

For security vulnerabilities, please see SECURITY.md.

License

MIT

Support