toTextStyle method

TextStyle toTextStyle({
  1. Color? color,
  2. Color? backgroundColor,
  3. Color? decorationColor,
  4. bool bold = false,
  5. bool italic = false,
  6. bool underline = false,
  7. bool doubleUnderline = false,
  8. TextDecorationStyle decorationStyle = TextDecorationStyle.solid,
  9. bool strikethrough = false,
  10. 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,
  );
}