copyWith method
Text
copyWith({
- String? data,
- Key? key,
- TextStyle? style,
- StrutStyle? strutStyle,
- TextAlign? textAlign,
- TextDirection? textDirection,
- Locale? locale,
- bool? softWrap,
- TextOverflow? overflow,
- double? textScaleFactor,
- int? maxLines,
- String? semanticsLabel,
- TextWidthBasis? textWidthBasis,
- TextHeightBehavior? textHeightBehavior,
todo 手机号中间四位省略为*号,或类似场景。正则? truncationMode leading tail middle todo 艺术字效果 边框、渐变…… foreground paint
Implementation
// String phoneNumber = '13888888888';
// String phoneNumberStr = phoneNumber.replaceFirst(RegExp(r'\d{4}'), '****', 3);
///todo 艺术字效果 边框、渐变……
///foreground paint
Text copyWith({
String? data,
Key? key,
TextStyle? style,
StrutStyle? strutStyle,
TextAlign? textAlign,
TextDirection? textDirection,
Locale? locale,
bool? softWrap,
TextOverflow? overflow,
double? textScaleFactor,
int? maxLines,
String? semanticsLabel,
TextWidthBasis? textWidthBasis,
TextHeightBehavior? textHeightBehavior,
}) {
return Text(data ?? this.data!,
key: key ?? this.key,
style: style ?? this.style,
strutStyle: strutStyle ?? this.strutStyle,
textAlign: textAlign ?? this.textAlign,
textDirection: textDirection ?? this.textDirection,
locale: locale ?? this.locale,
softWrap: softWrap ?? this.softWrap,
overflow: overflow ?? this.overflow,
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
maxLines: maxLines ?? this.maxLines,
semanticsLabel: semanticsLabel ?? this.semanticsLabel,
textWidthBasis: textWidthBasis ?? this.textWidthBasis,
textHeightBehavior: textHeightBehavior ?? this.textHeightBehavior);
}