copyWith method
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,
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;
}