computeDistanceToActualBaseline method

  1. @override
double? computeDistanceToActualBaseline(
  1. TextBaseline baseline
)
override

Returns the distance from the y-coordinate of the position of the box to the y-coordinate of the first given baseline in the box's contents, if any, or null otherwise.

Do not call this function directly. If you need to know the baseline of a child from an invocation of performLayout or paint, call getDistanceToBaseline.

Subclasses should override this method to supply the distances to their baselines. When implementing this method, there are generally three strategies:

Implementation

@override
double? computeDistanceToActualBaseline(TextBaseline baseline) {
  double? result;
  final RenderBox? child = this.child;
  assert(!debugNeedsLayout);
  if (child != null) {
    assert(!child.debugNeedsLayout);
    result = child.getDistanceToActualBaseline(baseline);
    final BoxParentData childParentData = child.parentData! as BoxParentData;
    if (result != null) {
      result += childParentData.offset.dy;
    }
  } else {
    result = super.computeDistanceToActualBaseline(baseline);
  }
  return result;
}