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.
Used by certain layout models to align adjacent boxes on a common
baseline, regardless of padding, font size differences, etc. If there is
no baseline, this function returns the distance from the y-coordinate of
the position of the box to the y-coordinate of the bottom of the box
(i.e., the height of the box) unless the caller passes true
for onlyReal
, in which case the function returns null.
Only call this function after calling layout on this box. You are only allowed to call this from the parent of this box during that parent's performLayout or paint functions.
Source
double getDistanceToBaseline(TextBaseline baseline, { bool onlyReal: false }) { assert(!needsLayout); assert(!_debugDoingBaseline); assert(() { final RenderObject parent = this.parent; if (owner.debugDoingLayout) return (RenderObject.debugActiveLayout == parent) && parent.debugDoingThisLayout; if (owner.debugDoingPaint) return ((RenderObject.debugActivePaint == parent) && parent.debugDoingThisPaint) || ((RenderObject.debugActivePaint == this) && debugDoingThisPaint); assert(parent == this.parent); return false; }); assert(_debugSetDoingBaseline(true)); double result = getDistanceToActualBaseline(baseline); assert(_debugSetDoingBaseline(false)); if (result == null && !onlyReal) return size.height; return result; }