merge static method
Will merge two DrawablePaints, preferring properties defined in a
if they're not null.
If a
is identical
with DrawablePaint.empty, b
will be ignored.
Implementation
static DrawablePaint? merge(DrawablePaint? a, DrawablePaint? b) {
if (a == null && b == null) {
return null;
}
if (b == null && a != null) {
return a;
}
if (identical(a, DrawablePaint.empty) ||
identical(b, DrawablePaint.empty)) {
return a ?? b;
}
if (a == null) {
return b;
}
// If we got here, the styles should not be null.
assert(a.style == b!.style,
'Cannot merge Paints with different PaintStyles; got:\na: $a\nb: $b.');
b = b!;
return DrawablePaint(
a.style ?? b.style,
color: a.color ?? b.color,
shader: a.shader ?? b.shader,
blendMode: a.blendMode ?? b.blendMode,
colorFilter: a.colorFilter ?? b.colorFilter,
isAntiAlias: a.isAntiAlias ?? b.isAntiAlias,
filterQuality: a.filterQuality ?? b.filterQuality,
maskFilter: a.maskFilter ?? b.maskFilter,
strokeCap: a.strokeCap ?? b.strokeCap,
strokeJoin: a.strokeJoin ?? b.strokeJoin,
strokeMiterLimit: a.strokeMiterLimit ?? b.strokeMiterLimit,
strokeWidth: a.strokeWidth ?? b.strokeWidth,
);
}