clipCorners method
Applies an ClipEffect to a Widget with the given clip
and a
corners
.
Implementation
Widget clipCorners(
List<double> corners, {
Clip? clip,
List<double>? from,
}) {
final length = corners.length;
assert(length != 3 && length <= 4, 'Corners must have 1, 2 or 4 values');
final BorderRadius? borderRadiusFrom = from == null
? null
: switch (from) {
[num all] => BorderRadius.circular(all.toDouble()),
[num horizontal, num vertical] => BorderRadius.only(
topLeft: Radius.circular(horizontal.toDouble()),
topRight: Radius.circular(horizontal.toDouble()),
bottomRight: Radius.circular(vertical.toDouble()),
bottomLeft: Radius.circular(vertical.toDouble()),
),
[num topLeft, num topRight, num bottomRight, num bottomLeft] =>
BorderRadius.only(
topLeft: Radius.circular(topLeft.toDouble()),
topRight: Radius.circular(topRight.toDouble()),
bottomRight: Radius.circular(bottomRight.toDouble()),
bottomLeft: Radius.circular(bottomLeft.toDouble()),
),
_ => BorderRadius.zero
};
final BorderRadius borderRadiusTo = switch (corners) {
[num all] => BorderRadius.circular(all.toDouble()),
[num horizontal, num vertical] => BorderRadius.only(
topLeft: Radius.circular(horizontal.toDouble()),
topRight: Radius.circular(horizontal.toDouble()),
bottomRight: Radius.circular(vertical.toDouble()),
bottomLeft: Radius.circular(vertical.toDouble()),
),
[num topLeft, num topRight, num bottomRight, num bottomLeft] =>
BorderRadius.only(
topLeft: Radius.circular(topLeft.toDouble()),
topRight: Radius.circular(topRight.toDouble()),
bottomRight: Radius.circular(bottomRight.toDouble()),
bottomLeft: Radius.circular(bottomLeft.toDouble()),
),
_ => BorderRadius.zero
};
return EffectWidget(
start: borderRadiusFrom == null
? null
: ClipEffect(
clip: clip ?? Clip.antiAlias,
borderRadius: borderRadiusFrom,
),
end: ClipEffect(
clip: clip ?? Clip.antiAlias,
borderRadius: borderRadiusTo,
),
child: this,
);
}