BoxEdge.nonNull constructor

BoxEdge.nonNull(
  1. BoxEdge? other
)

Takes a possibly null box edge, with possibly null metrics, and fills them in with 0 instead.

Implementation

factory BoxEdge.nonNull(BoxEdge? other) {
  if (other == null) return const BoxEdge(0, 0, 0, 0);
  var left = other.left;
  var top = other.top;
  var right = other.right;
  var bottom = other.bottom;
  var make = false;
  if (left == null) {
    make = true;
    left = 0;
  }
  if (top == null) {
    make = true;
    top = 0;
  }
  if (right == null) {
    make = true;
    right = 0;
  }
  if (bottom == null) {
    make = true;
    bottom = 0;
  }
  return make ? BoxEdge(left, top, right, bottom) : other;
}