merge method Null safety

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.none is returned.

The arguments must not be null.


static BorderSide merge(BorderSide a, BorderSide b) {
  assert(a != null);
  assert(b != null);
  assert(canMerge(a, b));
  final bool aIsNone = == BorderStyle.none && a.width == 0.0;
  final bool bIsNone = == 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( ==;
  return BorderSide(
    color: a.color, // == b.color
    width: a.width + b.width,
    style:, // ==