selfprivacy.org.app/lib/utils/extensions/text_extensions.dart

51 lines
1.6 KiB
Dart
Raw Normal View History

2021-07-29 08:24:42 +03:00
import 'package:flutter/cupertino.dart';
extension TextExtension on Text {
Text withColor(Color color) => Text(
data!,
2022-05-24 21:55:39 +03:00
key: key,
strutStyle: strutStyle,
textAlign: textAlign,
textDirection: textDirection,
locale: locale,
softWrap: softWrap,
overflow: overflow,
textScaleFactor: textScaleFactor,
maxLines: maxLines,
semanticsLabel: semanticsLabel,
textWidthBasis: textWidthBasis ?? textWidthBasis,
style: style != null
? style!.copyWith(color: color)
2021-07-29 08:24:42 +03:00
: TextStyle(color: color),
);
Text copyWith({
Key? key,
StrutStyle? strutStyle,
TextAlign? textAlign,
TextDirection? textDirection,
Locale? locale,
bool? softWrap,
TextOverflow? overflow,
double? textScaleFactor,
int? maxLines,
String? semanticsLabel,
TextWidthBasis? textWidthBasis,
TextStyle? style,
}) {
return Text(data!,
key: key ?? this.key,
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,
style: style != null ? this.style?.merge(style) ?? style : this.style);
}
}