copyWith method

TextStyle copyWith ({Color color, String fontFamily, double fontSize, FontWeight fontWeight, FontStyle fontStyle, double letterSpacing, double wordSpacing, TextBaseline textBaseline, double height, Locale locale, Paint foreground, Paint background, List<Shadow> shadows, TextDecoration decoration, Color decorationColor, TextDecorationStyle decorationStyle, String debugLabel })

Creates a copy of this text style but with the given fields replaced with the new values.

One of color or foreground must be null, and if this has foreground specified it will be given preference over any color parameter.

Implementation

TextStyle copyWith({
  Color color,
  String fontFamily,
  double fontSize,
  FontWeight fontWeight,
  FontStyle fontStyle,
  double letterSpacing,
  double wordSpacing,
  TextBaseline textBaseline,
  double height,
  Locale locale,
  Paint foreground,
  Paint background,
  List<ui.Shadow> shadows,
  TextDecoration decoration,
  Color decorationColor,
  TextDecorationStyle decorationStyle,
  String debugLabel,
}) {
  assert(color == null || foreground == null, _kColorForegroundWarning);
  String newDebugLabel;
  assert(() {
    if (this.debugLabel != null)
      newDebugLabel = debugLabel ?? '(${this.debugLabel}).copyWith';
    return true;
  }());
  return TextStyle(
    inherit: inherit,
    color: this.foreground == null && foreground == null ? color ?? this.color : null,
    fontFamily: fontFamily ?? this.fontFamily,
    fontSize: fontSize ?? this.fontSize,
    fontWeight: fontWeight ?? this.fontWeight,
    fontStyle: fontStyle ?? this.fontStyle,
    letterSpacing: letterSpacing ?? this.letterSpacing,
    wordSpacing: wordSpacing ?? this.wordSpacing,
    textBaseline: textBaseline ?? this.textBaseline,
    height: height ?? this.height,
    locale: locale ?? this.locale,
    foreground: foreground ?? this.foreground,
    background: background ?? this.background,
    shadows: shadows ?? this.shadows,
    decoration: decoration ?? this.decoration,
    decorationColor: decorationColor ?? this.decorationColor,
    decorationStyle: decorationStyle ?? this.decorationStyle,
    debugLabel: newDebugLabel,
  );
}