copyWith method

Text copyWith({
  1. Key? key,
  2. StrutStyle? strutStyle,
  3. TextAlign? textAlign,
  4. TextDirection? textDirection = TextDirection.ltr,
  5. Locale? locale,
  6. bool? softWrap,
  7. TextOverflow? overflow,
  8. TextScaler? textScaler,
  9. int? maxLines,
  10. String? semanticsLabel,
  11. TextWidthBasis? textWidthBasis,
  12. TextStyle? style,
})

Helper to apply changes.

Implementation

Text copyWith({
  Key? key,
  StrutStyle? strutStyle,
  TextAlign? textAlign,
  TextDirection? textDirection = TextDirection.ltr,
  Locale? locale,
  bool? softWrap,
  TextOverflow? overflow,
  TextScaler? textScaler,
  int? maxLines,
  String? semanticsLabel,
  TextWidthBasis? textWidthBasis,
  TextStyle? style,
}) {
  final Text text = this;
  final Text copy = _plainCopy(
    key: key,
    strutStyle: strutStyle,
    textAlign: textAlign,
    textDirection: textDirection,
    locale: locale,
    softWrap: softWrap,
    overflow: overflow,
    textScaler: textScaler,
    maxLines: maxLines,
    semanticsLabel: semanticsLabel,
    textWidthBasis: textWidthBasis,
    style: style != null ? this.style?.merge(style) ?? style : this.style,
  );
  if (text is _ThemedText) {
    return _ThemedText.like(
      copy,
      select: text.select,
      overrides: style != null
          ? text.overrides?.merge(style) ?? style
          : text.overrides,
    );
  }
  return copy;
}