Generates type-safe copyWith extensions for Dart classes
open sourceMITfree
copy_with_extension generates type-safe copyWith extensions for Dart classes and record typedefs annotated with @CopyWith(), through a build_runner builder (copy_with_extension_gen). The generated API copies immutable objects while changing one field (copyWith.fieldName(...)), several at once (copyWith(...)) or setting fields to null (copyWithNull).
Problems it solves
- generate copyWith methods for immutable Dart classes
- update one field of an immutable Flutter state object
- avoid writing copyWith by hand in Dart
Features
- @CopyWith annotation for classes and record typedefs
- field-by-field and multi-field copyWith
- copyWithNull to clear fields
- build_runner code generation
Alternatives
The same job
These do what copy_with_extension does.
- code_builder A fluent, builder-based library for generating valid Dart code
