67 lines
1.5 KiB
Dart
67 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class TextWidget extends StatelessWidget {
|
|
const TextWidget({
|
|
Key? key,
|
|
this.text,
|
|
this.fontSize,
|
|
this.color,
|
|
this.fontWeight,
|
|
this.fontFamily,
|
|
this.textAlign,
|
|
this.decoration,
|
|
this.overflow,
|
|
this.softWrap,
|
|
}) : super(key: key);
|
|
final String? text;
|
|
final double? fontSize;
|
|
final Color? color;
|
|
final FontWeight? fontWeight;
|
|
final String? fontFamily;
|
|
final TextAlign? textAlign;
|
|
final TextDecoration? decoration;
|
|
final TextOverflow? overflow;
|
|
final bool? softWrap;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Text(
|
|
text ?? '',
|
|
style: buildTextStyle(
|
|
fontSize: fontSize,
|
|
color: color,
|
|
fontWeight: fontWeight,
|
|
fontFamily: fontFamily,
|
|
),
|
|
|
|
overflow: overflow,
|
|
softWrap: softWrap ?? true,
|
|
textAlign: textAlign ?? TextAlign.center,
|
|
);
|
|
}
|
|
}
|
|
|
|
TextStyle buildTextStyle({
|
|
double? fontSize,
|
|
Color? color,
|
|
FontWeight? fontWeight,
|
|
double? letterSpacing,
|
|
double? wordSpacing,
|
|
List<Shadow>? shadows,
|
|
Color? backgroundColor,
|
|
double? height,
|
|
String? fontFamily,
|
|
}) {
|
|
return TextStyle(
|
|
letterSpacing: letterSpacing,
|
|
wordSpacing: wordSpacing,
|
|
fontSize: fontSize ?? 17,
|
|
color: color ?? Colors.black,
|
|
shadows: shadows,
|
|
fontFamily: fontFamily,
|
|
backgroundColor: backgroundColor,
|
|
fontWeight: fontWeight,
|
|
height: height,
|
|
overflow: TextOverflow.fade,
|
|
);
|
|
}
|