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) {
  final totalMargin = margin ?? const EdgeInsets.all(0);
  final totalPadding = padding ?? const EdgeInsets.all(0);
  final innerOffset = offset + Offset(totalMargin.left, totalMargin.top);
  final innerWidth = size!.width - totalMargin.left - totalMargin.right;
  final innerHeight = size!.height - totalMargin.top - totalMargin.bottom;

  _paintBackground(context, innerOffset, innerWidth, innerHeight);

  if (child != null) {
    final int borderLeft = _hasBorder && border!.left.isNotEmpty ? 1 : 0;
    final int borderTop = _hasBorder && border!.top.isNotEmpty ? 1 : 0;
    context.paintChild(
      child!,
      innerOffset +
          Offset(
            borderLeft + totalPadding.left,
            borderTop + totalPadding.top,
          ),
    );
  }

  if (_hasBorder) {
    _paintBorder(context, innerOffset, innerWidth, innerHeight);
  }
}