computeDistanceToActualBaseline method

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

The line's baseline is one item's (_baselineItem): where that item's text sits, or its bottom edge where it holds none -- so a line of boxes with no text still has one, as a flex container does. A line with no items has none. How deep the item is comes from the line as it was laid out: a child's own size is its parent's to read, and only while the parent lays it out -- not when the box laying the line out (a Row, a paragraph) asks where its baseline is.

Implementation

@override
double? computeDistanceToActualBaseline(TextBaseline baseline) {
  final item = _baselineItem(_placed?.first ?? const <_Item>[], (i) => i.data);
  if (item == null) return null;
  final depth = _row ? item.crossSize : item.mainSize;
  return item.data.offset.dy + _synthesized(item.child.getDistanceToActualBaseline(baseline), depth, item.data);
}