calculateBaseline method

  1. @override
void calculateBaseline()
override

Implementation

@override
void calculateBaseline() {
  final RenderBox? currentChild = child;
  double? childBase;

  if (currentChild is RenderBoxModel) {
    childBase =
        currentChild.computeCssFirstBaselineOf(TextBaseline.alphabetic);
  } else if (currentChild is RenderPositionPlaceholder) {
    childBase = currentChild.positioned
        ?.computeCssFirstBaselineOf(TextBaseline.alphabetic);
  }

  if (childBase == null && currentChild != null) {
    if (!currentChild.attached) {
      childBase = currentChild.hasSize ? currentChild.size.height : null;
    } else {
      childBase = currentChild.getDistanceToBaseline(TextBaseline.alphabetic);
    }
  }

  // Convert child's local baseline to this wrapper's coordinate system.
  if (childBase != null && currentChild is RenderBox) {
    final BoxParentData pd = currentChild.parentData as BoxParentData;
    childBase += pd.offset.dy;
  }

  setCssBaselines(first: childBase, last: childBase);
}