debugPaintBaselines method

  1. @protected
void debugPaintBaselines(
  1. PaintingContext context,
  2. Offset offset
)

In debug mode, paints a line for each baseline.

Called for every RenderBox when debugPaintBaselinesEnabled is true.

Implementation

@protected
void debugPaintBaselines(PaintingContext context, Offset offset) {
  assert(() {
    final Paint paint = Paint()
     ..style = PaintingStyle.stroke
     ..strokeWidth = 0.25;
    Path path;
    // ideographic baseline
    final double? baselineI = getDistanceToBaseline(TextBaseline.ideographic, onlyReal: true);
    if (baselineI != null) {
      paint.color = const Color(0xFFFFD000);
      path = Path();
      path.moveTo(offset.dx, offset.dy + baselineI);
      path.lineTo(offset.dx + size.width, offset.dy + baselineI);
      context.canvas.drawPath(path, paint);
    }
    // alphabetic baseline
    final double? baselineA = getDistanceToBaseline(TextBaseline.alphabetic, onlyReal: true);
    if (baselineA != null) {
      paint.color = const Color(0xFF00FF00);
      path = Path();
      path.moveTo(offset.dx, offset.dy + baselineA);
      path.lineTo(offset.dx + size.width, offset.dy + baselineA);
      context.canvas.drawPath(path, paint);
    }
    return true;
  }());
}