build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the UI represented by this widget.

Implementation

@override
Widget build(BuildContext context) {
  if (style == null) {
    return AsciiText(
      data: data,
      font: font,
      textAlign: textAlign,
      maxWidth: maxWidth,
    );
  }
  // Render the ASCII art, then apply the style per-line to avoid
  // Style.render()'s _alignLines() padding all lines to equal width.
  // This preserves each line's exact spacing (important for ASCII art
  // glyphs that may have different visible widths, e.g. trailing
  // empty lines in slim font).
  final rendered = _renderAsciiText(data, font, textAlign, maxWidth);
  final inlineStyle = style!.copy()..inline();
  final styledLines = rendered
      .split('\n')
      .map((line) => line.isEmpty ? line : inlineStyle.render(line))
      .join('\n');
  return Text(styledLines, softWrap: false);
}