comicCornerInset function

double comicCornerInset(
  1. OutlinedBorder? shape,
  2. TextDirection direction, {
  3. double? shortestSide,
})

Extra inset that keeps a rectangular content box clear of a rounded corner. Border dimensions reserve its stroke; this reserves the curved corner area. For a circle or capsule, pass the smaller side of its content bounds.

Implementation

double comicCornerInset(
  OutlinedBorder? shape,
  TextDirection direction, {
  double? shortestSide,
}) {
  double radius = 0;
  if (shape is RoundedRectangleBorder) {
    final r = shape.borderRadius.resolve(direction);
    radius = [
      r.topLeft.x,
      r.topLeft.y,
      r.topRight.x,
      r.topRight.y,
      r.bottomLeft.x,
      r.bottomLeft.y,
      r.bottomRight.x,
      r.bottomRight.y,
    ].reduce(math.max);
    if (shortestSide != null) radius = math.min(radius, shortestSide / 2);
  } else if (shape is CircleBorder || shape is StadiumBorder) {
    radius = (shortestSide ?? 0) / 2;
  }
  return radius * (1 - math.sqrt(.5));
}