minOf method

BaselineOffset minOf(
  1. BaselineOffset other
)

Compares this BaselineOffset and other, and returns whichever is closer to the origin.

When both this and other are noBaseline, this method returns noBaseline. When one of them is noBaseline, this method returns the other oprand that's not noBaseline.

Implementation

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