mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-18 14:49:15 +00:00
52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
import 'dart:ui';
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
extension TextExtension on Text {
|
|
Text withColor(Color color) => Text(
|
|
data!,
|
|
key: this.key,
|
|
strutStyle: this.strutStyle,
|
|
textAlign: this.textAlign,
|
|
textDirection: this.textDirection,
|
|
locale: this.locale,
|
|
softWrap: this.softWrap,
|
|
overflow: this.overflow,
|
|
textScaleFactor: this.textScaleFactor,
|
|
maxLines: this.maxLines,
|
|
semanticsLabel: this.semanticsLabel,
|
|
textWidthBasis: textWidthBasis ?? this.textWidthBasis,
|
|
style: this.style != null
|
|
? this.style!.copyWith(color: color)
|
|
: 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);
|
|
}
|
|
}
|