comicCappedShape function

OutlinedBorder comicCappedShape(
  1. OutlinedBorder shape,
  2. double most
)

shape with no corner above most: a rounded rectangle's corners are reduced by the same inset, so the result stays concentric with shape; other shapes are returned as they are.

comicCappedShape(theme.shapes.small, 7)

Implementation

OutlinedBorder comicCappedShape(OutlinedBorder shape, double most) {
  if (shape is! RoundedRectangleBorder) return shape;
  final r = shape.borderRadius.resolve(TextDirection.ltr);
  final largest = [
    r.topLeft.x,
    r.topRight.x,
    r.bottomLeft.x,
    r.bottomRight.x,
  ].reduce(math.max);
  return largest <= most ? shape : comicInsetShape(shape, largest - most);
}