render method

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

Implementation

@override
void render(Rect area, Buffer buffer, RenderContext ctx) {
  if (area.isEmpty) return;
  final isFocused = ctx.isFocused(id);
  for (var i = 0; i < options.length && i < area.height; i++) {
    final opt = options[i];
    final isSel = opt.value == selected;
    final mark = isSel ? '(•)' : '( )';
    final style = isFocused && isSel
        ? ctx.theme.text.body
            .copyWith(fg: ctx.theme.colors.primary, bold: true)
        : ctx.theme.text.body;
    buffer.writeText(area.x, area.y + i, '$mark ${opt.label}',
        style: style, maxWidth: area.width);
  }
}