mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-13 20:23:16 +00:00
52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
extension TextExtension on Text {
|
|
Text withColor(final Color color) => Text(
|
|
data!,
|
|
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)
|
|
: TextStyle(color: color),
|
|
);
|
|
|
|
Text copyWith({
|
|
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,
|
|
}) =>
|
|
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,
|
|
);
|
|
}
|