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 (totalPages <= 0 || area.width <= 0 || area.height <= 0) return;

  final current = currentPage.clamp(0, totalPages - 1);

  final dotChars = activeDot.characters;
  final inactiveDotChars = inactiveDot.characters;
  final separatorChars = separator.characters;

  var currentX = 0;
  for (var i = 0; i < totalPages; i++) {
    final isCurrent = i == current;
    final dot = isCurrent ? activeDot : inactiveDot;
    final dotLen = isCurrent ? dotChars.length : inactiveDotChars.length;
    final dotStyle = isCurrent ? activeStyle : inactiveStyle;

    if (currentX + dotLen > area.width) break;
    buffer.writeString(currentX, 0, dot, dotStyle);
    currentX += dotLen;

    if (i < totalPages - 1) {
      if (currentX + separatorChars.length > area.width) break;
      buffer.writeString(currentX, 0, separator, separatorStyle);
      currentX += separatorChars.length;
    }
  }
}