copyWith method

FdcFormatSettings copyWith({
  1. Object? locale = _fdcUnsetFormatSettingsValue,
  2. String? dateFormat,
  3. String? timeFormat,
  4. Object? dateTimeFormat = _fdcUnsetFormatSettingsValue,
  5. String? decimalSeparator,
  6. String? thousandSeparator,
  7. bool? showThousandSeparator,
})

Returns a copy with changed format settings.

locale and dateTimeFormat intentionally use sentinel parameters so copyWith() keeps the current nullable values, while copyWith(locale: null) or copyWith(dateTimeFormat: null) clears them. Passing non-null values for those parameters must still use String.

Implementation

FdcFormatSettings copyWith({
  Object? locale = _fdcUnsetFormatSettingsValue,
  String? dateFormat,
  String? timeFormat,
  Object? dateTimeFormat = _fdcUnsetFormatSettingsValue,
  String? decimalSeparator,
  String? thousandSeparator,
  bool? showThousandSeparator,
}) {
  if (!identical(locale, _fdcUnsetFormatSettingsValue) &&
      locale != null &&
      locale is! String) {
    throw ArgumentError.value(
      locale,
      'locale',
      'Expected String, null, or omitted value.',
    );
  }

  if (!identical(dateTimeFormat, _fdcUnsetFormatSettingsValue) &&
      dateTimeFormat != null &&
      dateTimeFormat is! String) {
    throw ArgumentError.value(
      dateTimeFormat,
      'dateTimeFormat',
      'Expected String, null, or omitted value.',
    );
  }

  return FdcFormatSettings(
    locale: identical(locale, _fdcUnsetFormatSettingsValue)
        ? this.locale
        : locale as String?,
    dateFormat: dateFormat ?? this.dateFormat,
    timeFormat: timeFormat ?? this.timeFormat,
    dateTimeFormat: identical(dateTimeFormat, _fdcUnsetFormatSettingsValue)
        ? this.dateTimeFormat
        : dateTimeFormat as String?,
    decimalSeparator: decimalSeparator ?? this.decimalSeparator,
    thousandSeparator: thousandSeparator ?? this.thousandSeparator,
    showThousandSeparator:
        showThousandSeparator ?? this.showThousandSeparator,
  );
}