toTextStyle method
TextStyle
toTextStyle(
{ - Color? color,
- Color? backgroundColor,
- Color? decorationColor,
- bool bold = false,
- bool italic = false,
- bool underline = false,
- bool doubleUnderline = false,
- TextDecorationStyle decorationStyle = TextDecorationStyle.solid,
- bool strikethrough = false,
- bool overline = false,
})
Implementation
TextStyle toTextStyle({
Color? color,
Color? backgroundColor,
Color? decorationColor,
bool bold = false,
bool italic = false,
bool underline = false,
bool doubleUnderline = false,
TextDecorationStyle decorationStyle = TextDecorationStyle.solid,
bool strikethrough = false,
bool overline = false,
}) {
final decorations = [
if (underline || doubleUnderline) TextDecoration.underline,
if (strikethrough) TextDecoration.lineThrough,
if (overline) TextDecoration.overline,
];
final decoration = switch (decorations.isEmpty) {
true => TextDecoration.none,
false => TextDecoration.combine(decorations),
};
final effectiveDecorationStyle = switch (doubleUnderline) {
true => TextDecorationStyle.double,
false => decorationStyle,
};
return TextStyle(
fontSize: fontSize,
height: height,
fontFamily: fontFamily,
fontFamilyFallback: fontFamilyFallback,
color: color,
backgroundColor: backgroundColor,
fontWeight: switch (bold) {
true => FontWeight.bold,
false => FontWeight.normal,
},
fontStyle: switch (italic) {
true => FontStyle.italic,
false => FontStyle.normal,
},
decoration: decoration,
decorationStyle: effectiveDecorationStyle,
decorationColor: decorationColor,
fontFeatures: _kTerminalFontFeatures,
);
}