paint method

  1. @override
void paint(
  1. PaintingContext context,
  2. Offset offset
)
override

Paints this render object into the given context at offset.

Implementation

@override
void paint(PaintingContext context, Offset offset) {
  for (int i = 0; i < items.length; i++) {
    final DropdownMenuItem item = items[i];
    final bool isSelected = i == selectedIndex;
    final Color bgColor = isSelected ? focusColor : dropdownColor;
    final Color fg = item.enabled ? Color.white : Color.brightBlack;
    final TextStyle bgStyle = TextStyle(backgroundColor: bgColor);
    final TextStyle fgBgStyle =
        TextStyle(color: fg, backgroundColor: bgColor);
    _fillRow(context, offset.x.toInt(), offset.y.toInt() + i,
        size!.width.toInt(), bgStyle);
    final String prefix = isSelected ? '> ' : '  ';
    _paintChars(
        context, offset.x.toInt(), offset.y.toInt() + i, prefix, fgBgStyle);
    _paintLabel(context, offset.x.toInt() + 2, offset.y.toInt() + i,
        item.label, fgBgStyle);
  }
}