copyWith<T> method

InheritedProperties copyWith<T>({
  1. InheritedProperties? parent,
  2. TextStyle? style,
  3. T? value,
})

Creates a copy with the given fields replaced with the new values.

Implementation

InheritedProperties copyWith<T>({
  InheritedProperties? parent,
  TextStyle? style,
  T? value,
}) {
  var newStyle = _style;
  if (style != null) {
    if (style.inherit) {
      newStyle = newStyle.merge(style);
    } else {
      newStyle = style;
    }
  }

  return InheritedProperties._(
    parent ?? this.parent,
    value != null ? [...values.where((e) => e is! T), value] : values,
    newStyle,
  );
}