field property

String? field
final

The field that should be used as the fallback in the copyWith() method

Example:

@CopyWith()
class Profile {
  final String _privateOne;
  final String _privateTwo;

  Profile({
    @CopyWithKey(field: "_privateOne")
    String? private,
  }) : _privateOne = private ?? "one", _privateTwo = private ?? "two";
}

This is necessary, when a constructor parameter is used to assign multiple fields.

In probably every case, this can be avoided (e.g. using a factory constructor or using getter methods instead).

Do only set this when the annotation is used on a constructor parameter

Implementation

final String? field;