copyWith method

TranslatedName copyWith({
  1. String? countryCode,
  2. String? fullName,
  3. NaturalLanguage? language,
  4. String? name,
  5. Script? script,
})

Creates a copy of this object with the given fields replaced with the new values.

For nullable fields, passing null leaves the field unchanged (standard Dart copyWith behavior). To explicitly reset a nullable field to null, pass a domain-invalid sentinel value:

  • String? fields: pass an empty string (isEmpty) to reset to null.
  • List? / Set? fields: pass an empty collection (isEmpty) to reset to null.
  • double?/int? fields (positive-only, e.g. height/width/angle): pass a negative value (isNegative) to reset to null.

These sentinel values are never valid for the respective fields (enforced by constructor assertions), making the intent unambiguous.

Implementation

TranslatedName copyWith({
  String? countryCode,
  String? fullName,
  NaturalLanguage? language,
  String? name,
  Script? script,
}) => TranslatedName(
  language ?? this.language,
  name: name ?? this.name,
  fullName: (fullName?.isEmpty ?? false) ? null : (fullName ?? this.fullName),
  countryCode: (countryCode?.isEmpty ?? false)
      ? null
      : (countryCode ?? this.countryCode),
  script: script ?? this.script,
);