flutter_feature_generator 2.2.0 copy "flutter_feature_generator: ^2.2.0" to clipboard
flutter_feature_generator: ^2.2.0 copied to clipboard

A powerful code generator with web interface for creating clean architecture features in Flutter projects from OpenAPI/Swagger specifications.

Changelog #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

2.2.0 #

Major New Features #

Swagger File Upload Support

  • Browser-Based File Selection: Upload swagger.json directly through the web interface
  • Default File Detection: Automatically uses swagger.json from project root if available
  • Dynamic File Switching: Change Swagger file anytime without restarting the server
  • Graceful Error Handling: No errors when swagger.json is missing - just upload one!
  • Status Indicators: Visual feedback showing loaded Swagger file and endpoint count

Dependency Injection (DI) Setup

  • One-Click DI Generation: New "Setup DI" button creates complete DI structure
  • GetIt Integration: Generates lib/di/injection_container.dart with GetIt configuration
  • Injectable Configuration: Creates app_module.dart with @module annotations
  • Environment-Based URLs: Automatic dev/prod base URL configuration
  • Dio Pre-Configuration: Ready-to-use Dio instance with 60s timeouts and proper headers
  • Auth Interceptor Template: interceptors.dart with auth token injection template
  • Smart Detection: Checks existing files and skips if already present

Project Setup Automation

  • Add Dependencies Button: One-click addition of all required packages to pubspec.yaml
    • Automatically adds: dartz, injectable, get_it, freezed_annotation, json_annotation, retrofit, dio, build_runner, freezed, json_serializable, retrofit_generator, injectable_generator
    • Smart duplicate detection - only adds missing dependencies
    • Properly formats SDK dependencies (flutter_localizations)
  • Localization Setup: New "Setup Localization" button
    • Creates lib/l10n/ folder with app_en.arb
    • Generates l10n.yaml with proper configuration
    • Adds flutter_localizations SDK dependency
    • Ready for flutter gen-l10n command

Core Files Control

  • Optional Core File Generation: Core files (Error class, API Constants) are now opt-in
  • Error Class Checkbox: Generate lib/core/error/error.dart only when needed
  • API Constants Checkbox: Generate lib/core/utils/api_constants.dart with minimalistic template
  • Exists Indicators: Visual "✓ Exists" badges show which core files are already present
  • No Auto-Generation: Core files are ONLY generated when explicitly selected

Critical Bug Fixes #

Model Naming Convention Fix

  • Intelligent Case Conversion: Properly handles all casing formats
    • Input: casestatus → Output: CaseStatus class in case_status.dart
    • Input: caseStatus (camelCase) → Output: CaseStatus in case_status.dart
    • Input: CaseStatus (PascalCase) → Output: CaseStatus in case_status.dart
    • Input: case-status (kebab-case) → Output: CaseStatus in case_status.dart
  • Applied to All Templates: Fixed naming in models, blocs, services, use cases, sources, repositories, and screens
  • Consistent Formatting: Ensures proper snake_case filenames and PascalCase class names

Architecture Improvements #

Enhanced File Management

  • Explicit User Control: All file generation requires explicit user action
  • Smart Existence Checks: Real-time checking and display of existing files
  • Flexible Project Structure: Supports projects with or without swagger.json

Better Error Handling

  • Graceful Missing File: No errors when swagger.json not found
  • Empty State Handling: Proper UI state when no endpoints loaded
  • Validation Messages: Clear feedback for invalid selections
  • Type-Safe Operations: Eliminated type casting errors

Technical Improvements #

Code Generation

  • Dynamic Project Name: All templates use detected project name
  • Template Updates: Applied naming fixes to all 7 template files
  • Import Management: Proper imports for all generated DI files

State Management

  • Swagger Status Tracking: Monitors loaded file and endpoint count
  • Core Status Tracking: Tracks existence of core files
  • Real-time Updates: UI updates after each operation

Generated File Templates #

Dependency Injection Files

  • Complete GetIt + Injectable setup
  • Environment-based configuration
  • Pre-configured Dio with interceptors
  • Auth token injection template

Localization Files

  • Basic ARB file with sample translations
  • Proper l10n.yaml configuration
  • Flutter gen-l10n ready

Workflow Changes #

New Project Setup Flow:

  1. Open web interface (automatic)
  2. Upload swagger.json or use existing one
  3. Click "Add Dependencies" to install packages
  4. Click "Setup DI" to create dependency injection structure
  5. Click "Setup Localization" if needed
  6. Select endpoints and configure layers
  7. Check core files if needed (Error, API Constants)
  8. Generate feature

User Experience #

  • Reduced Friction: One-click operations for common tasks
  • Visual Feedback: Always know what's happening
  • Smart Defaults: Sensible defaults with full control
  • No Surprises: Explicit opt-in for all file generation
  • Easy Recovery: Can always regenerate or modify files

Quality of Life #

  • Faster Setup: New projects ready in seconds
  • Consistent Structure: All projects follow same DI pattern
  • Less Manual Work: Automate dependency management
  • Better Naming: Proper case handling for all inputs
  • Cleaner Code: No syntax errors from comma/casting issues

2.1.0 #

New Features #

  • Smart Nested Model Generation: Automatically generates separate model classes for nested objects instead of using Map<String, dynamic>
  • Enhanced Type Safety: Proper Dart types for all nested structures (e.g., List<User> instead of List<Map<String, dynamic>>)
  • Automatic $ref Resolution: Resolves $ref references from components/schemas and generates corresponding models
  • Recursive Nested Object Handling: Supports deeply nested objects with automatic extraction and model generation
  • Smart Import Management: Automatically adds required imports for nested and referenced models

Improvements #

  • Better Model Structure: Inline objects in arrays now generate dedicated model classes
  • Referenced Model Support: Models referenced via $ref are automatically detected and generated
  • Freezed Integration: All nested models use Freezed annotations for immutability and JSON serialization
  • Type-Safe Code Generation: Eliminates the need for runtime type casting with proper model classes

Technical Details #

  • New extractNestedModels() method to recursively find nested object schemas
  • New _generateModelWithNested() method for hierarchical model generation
  • Enhanced _getDartType() to properly resolve type references
  • Automatic dependency tracking for nested model imports

2.0.3 #

Critical Bug Fixes #

  • BREAKING FIX: Resolved hardcoded package name in all generated imports
  • All generated code now uses the correct project package name instead of hardcoded references
  • Fixed imports in data layer, domain layer, presentation layer, and error handling classes

2.0.2 #

Code Quality Improvements #

  • Removed dead code in feature_generator.dart that was unreachable after return statement
  • Cleaned up unused imports (shelf_static in web_server.dart, direct web_server import in main)
  • Removed unused shelf_static dependency from pubspec.yaml

2.0.1 #

Bug Fixes #

  • Updated documentation with proper image handling instructions for pub.dev

2.0.0 #

🎉 Major Features Added #

  • Interactive Web Interface: Beautiful, modern web UI for API selection and feature generation
  • Granular Layer Control: Choose specific layers to generate (Data, Domain, Presentation)
  • Presentation Component Selection: Fine-grained control over BLoC, Screens, and Widgets
  • Smart Appending: Automatically appends to existing classes instead of overwriting
  • Auto-Generated Core Files: Automatically creates core/error/error.dart if missing
  • Real-time Search: Filter APIs by path, method, tag, or description
  • Multi-Selection Interface: Visual selection of multiple endpoints with feedback

🌐 Web Interface Features #

  • Responsive design that works on desktop and mobile
  • Real-time API endpoint loading from swagger.json
  • Interactive checkboxes for layer and component selection
  • Search and filter functionality for large API specifications
  • Visual feedback with progress indicators and status messages
  • Automatic feature name validation with helpful error messages

🏗️ Architecture Improvements #

  • Consolidated Classes: New endpoints are added as methods to existing classes instead of creating separate classes
  • Smart Use Cases: Adds methods to main UseCases class instead of creating individual use case classes
  • Freezed Integration: Properly adds factory methods to freezed Event classes and fields to State classes
  • BLoC Enhancement: Adds new event handlers to existing BLoC classes
  • Repository Updates: Appends methods to existing repository interfaces and implementations
  • Source Layer Updates: Appends methods to existing source interfaces and implementations

🎛️ Granular Control #

  • Data Layer: Models, Services, Repository (can be selected independently)
  • Domain Layer: Use Cases, Repository Interface (can be selected independently)
  • Presentation Layer: Now has sub-components:
    • BLoC (Events, States, Business Logic)
    • Screens (UI Screens)
    • Widgets (Custom Widgets folder)

🔄 Smart Appending Logic #

  • Detects existing features automatically
  • Only adds new endpoints that don't already exist
  • Preserves existing code structure and formatting
  • Adds required imports automatically
  • Maintains consistent code patterns

🚀 Enhanced User Experience #

  • Layer selection with visual hierarchy
  • Presentation sub-component controls
  • Real-time validation feedback
  • Detailed success messages showing what was generated/updated
  • Clear error messages with helpful guidance

📦 Technical Improvements #

  • Auto-generation of core Error class with freezed unions for functional error handling
  • Improved error handling and user feedback
  • Better code organization with separation of concerns
  • Enhanced CLI backward compatibility
  • Comprehensive documentation of required dependencies

🐛 Bug Fixes #

  • Improved file path handling across different operating systems
  • Better error messages for invalid feature names and selections
  • Fixed duplicate endpoint detection logic

💔 Breaking Changes #

  • Default behavior now starts web interface instead of CLI (use specific arguments for CLI mode)
  • Minimum Dart SDK version remains 3.0.0
  • Generated code structure remains the same, but appending logic is significantly improved

1.0.7 #

Added #

  • Improved error handling for Windows PowerShell input issues
  • Better debug output for troubleshooting input problems
  • Enhanced user guidance with example commands

Fixed #

  • Windows PowerShell stdin reading issues
  • Input buffer clearing problems
  • Improved cross-platform input handling

1.0.0 #

Added #

  • Initial release of Flutter Feature Generator
  • Interactive API endpoint selection from Swagger/OpenAPI specs
  • Clean architecture feature generation
  • Name validation to prevent conflicts with reserved names
  • Support for append mode to add APIs to existing features
  • Command line interface with configurable options
  • Automatic project root detection when running from tool directory

Features #

  • Generate complete feature structure following clean architecture
  • Parse OpenAPI/Swagger specifications
  • Create data, domain, and presentation layers
  • Generate models, services, repositories, use cases, and BLoCs
  • Prevent naming conflicts with restricted folder names
  • Cross-platform support (Windows, macOS, Linux)

Technical #

  • Built with Dart 3.0+
  • Uses path package for cross-platform file operations
  • Args package for command line argument parsing
  • Proper error handling and user feedback
5
likes
150
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

A powerful code generator with web interface for creating clean architecture features in Flutter projects from OpenAPI/Swagger specifications.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

args, path, shelf, shelf_router

More

Packages that depend on flutter_feature_generator