add method
- @override
override
Attempts to create a new object that represents the amalgamation of this
border and the other
border.
If the type of the other border isn't known, or the given instance cannot be reasonably added to this instance, then this should return null.
This method is used by the operator + implementation.
The reversed
argument is true if this object was the right operand of
the +
operator, and false if it was the left operand.
Implementation
@override
BoxBorder add(ShapeBorder other, { bool reversed = false }) {
if (other is BorderDirectional) {
final BorderDirectional typedOther = other;
if (BorderSide.canMerge(top, typedOther.top) &&
BorderSide.canMerge(start, typedOther.start) &&
BorderSide.canMerge(end, typedOther.end) &&
BorderSide.canMerge(bottom, typedOther.bottom)) {
return BorderDirectional.merge(this, typedOther);
}
return null;
}
if (other is Border) {
final Border typedOther = other;
if (!BorderSide.canMerge(typedOther.top, top) ||
!BorderSide.canMerge(typedOther.bottom, bottom))
return null;
if (start != BorderSide.none ||
end != BorderSide.none) {
if (typedOther.left != BorderSide.none ||
typedOther.right != BorderSide.none)
return null;
assert(typedOther.left == BorderSide.none);
assert(typedOther.right == BorderSide.none);
return BorderDirectional(
top: BorderSide.merge(typedOther.top, top),
start: start,
end: end,
bottom: BorderSide.merge(typedOther.bottom, bottom),
);
}
assert(start == BorderSide.none);
assert(end == BorderSide.none);
return Border(
top: BorderSide.merge(typedOther.top, top),
right: typedOther.right,
bottom: BorderSide.merge(typedOther.bottom, bottom),
left: typedOther.left,
);
}
return null;
}