getDistanceToBaseline method

double? getDistanceToBaseline(
  1. LayoutTextBaseline baseline
)

Calculates the distance from the top of the box to its baseline.

Returns the offset to the specified text baseline, or null if this box doesn't have a baseline. The calculation considers the layout's main axis to determine which baseline computation method to use.

Implementation

double? getDistanceToBaseline(LayoutTextBaseline baseline) {
  return switch (boxLayout.mainAxis) {
    LayoutAxis.horizontal => defaultComputeDistanceToHighestActualBaseline(
      baseline,
    ),
    LayoutAxis.vertical => defaultComputeDistanceToFirstActualBaseline(
      baseline,
    ),
  };
}