minOf method

Returns the minimum baseline offset between this and another.

When comparing two baselines:

  • If both have values, returns the one with the smaller offset
  • If one is null, returns the non-null one
  • If both are null, returns null

Implementation

LayoutBaselineOffset minOf(LayoutBaselineOffset other) {
  return switch ((this, other)) {
    (final double lhs?, final double rhs?) => lhs >= rhs ? other : this,
    (final double lhs?, null) => LayoutBaselineOffset(lhs),
    (null, final LayoutBaselineOffset rhs) => rhs,
  };
}