merge method

BorderSide merge (
  1. BorderSide a,
  2. BorderSide b
)

Creates a BorderSide that represents the addition of the two given BorderSides.

It is only valid to call this if canMerge returns true for the two sides.

If one of the sides is zero-width with BorderStyle.none, then the other side is return as-is. If both of the sides are zero-width with BorderStyle.none, then BorderSide.zero is returned.

The arguments must not be null.

Implementation

static BorderSide merge(BorderSide a, BorderSide b) {
  assert(a != null);
  assert(b != null);
  assert(canMerge(a, b));
  final bool aIsNone = a.style == BorderStyle.none && a.width == 0.0;
  final bool bIsNone = b.style == BorderStyle.none && b.width == 0.0;
  if (aIsNone && bIsNone)
    return BorderSide.none;
  if (aIsNone)
    return b;
  if (bIsNone)
    return a;
  assert(a.color == b.color);
  assert(a.style == b.style);
  return BorderSide(
    color: a.color, // == b.color
    width: a.width + b.width,
    style: a.style, // == b.style
  );
}