render method

  1. @override
void render(
  1. Buffer buffer,
  2. Rect area
)
override

Renders the widget onto the provided buffer within the specified area.

Implementation

@override
void render(Buffer buffer, Rect area) {
  if (area.width <= 0 || area.height < 5) return;

  final activeSt = Style(foreground: activeColor);
  final inactiveSt = Style(foreground: inactiveColor);

  int offsetX = 0;
  for (int i = 0; i < value.length; i++) {
    final char = value[i];
    final matrix = _digits[char] ?? _digits[' '];

    if (matrix != null) {
      for (int y = 0; y < 5; y++) {
        for (int x = 0; x < 5; x++) {
          if (offsetX + x < area.width && y < area.height) {
            final active = matrix[y][x] == 1;
            buffer.writeString(
              offsetX + x,
              y,
              '█',
              active ? activeSt : inactiveSt,
            );
          }
        }
      }
      offsetX += 6; // 5 width + 1 spacing
    }
  }
}