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

52 lines
1.7 KiB
Dart
Raw Normal View History

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