FLUTTER ECOSYSTEM

copy_with_extension_gen

Automatically generating `copyWith` extensions code for classes with `@CopyWith()` annotation.

Latest version
15.0.1
30-day downloads
101.2K
Likes
219
Pub points
160

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Overview

A code generation package that automatically creates `copyWith` extension methods for Dart classes annotated with `@CopyWith()`. It simplifies immutable object updates by generating boilerplate-free, type-safe copy operations. Ideal for state management and data modeling in Flutter apps, reducing manual coding and potential errors. The generated extensions support nested objects and preserve null safety. Works seamlessly across all major platforms.

Use cases
  • State management in Flutter apps
  • Immutable data class updates
  • Reducing boilerplate in model classes
  • Streamlined JSON serialization workflows
  • Refactoring large data models
Key features
  • Auto-generates `copyWith` extensions
  • Supports nested and complex types
  • Null safety compliant
  • Minimal setup with annotations
  • Cross-platform compatibility
Suitable for
  • Developers using immutable data classes
  • Teams prioritizing code maintainability
  • Projects with heavy use of value objects
  • Flutter apps with complex state logic
  • Code generation enthusiasts
Considerations
  • Requires build_runner for code generation
  • Needs proper annotation on target classes
  • May increase build time slightly
  • Not suitable for runtime-only scenarios
  • Limited to classes with `@CopyWith()` annotation
Supported platformsAndroidiOSmacOSWindowsLinux

Install package

flutter pub add copy_with_extension_gen

Categories

Source repository

Related projects

Rankings