tryToMerge static method

Merges border instances with type conversion.

Implementation

static BoxBorderMix? tryToMerge(BoxBorderMix? a, BoxBorderMix? b) {
  if (b == null) return a;
  if (a == null) return b;

  return switch ((a, b)) {
    (BorderMix first, BorderMix second) => first.merge(second),
    (BorderDirectionalMix first, BorderDirectionalMix second) => first.merge(
      second,
    ),
    (BorderMix first, BorderDirectionalMix second) =>
      first._asBorderDirectional().merge(second),
    (BorderDirectionalMix first, BorderMix second) => first._asBorder().merge(
      second,
    ),
  };
}