merge method Null safety

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

Creates a BorderDirectional that represents the addition of the two given BorderDirectionals.

It is only valid to call this if BorderSide.canMerge returns true for the pairwise combination of each side on both BorderDirectionals.

The arguments must not be null.

Implementation

static BorderDirectional merge(BorderDirectional a, BorderDirectional b) {
  assert(a != null);
  assert(b != null);
  assert(BorderSide.canMerge(a.top, b.top));
  assert(BorderSide.canMerge(a.start, b.start));
  assert(BorderSide.canMerge(a.end, b.end));
  assert(BorderSide.canMerge(a.bottom, b.bottom));
  return BorderDirectional(
    top: BorderSide.merge(a.top, b.top),
    start: BorderSide.merge(a.start, b.start),
    end: BorderSide.merge(a.end, b.end),
    bottom: BorderSide.merge(a.bottom, b.bottom),
  );
}