comicOutsetShape function

OutlinedBorder comicOutsetShape(
  1. OutlinedBorder shape,
  2. double gap
)

The concentric shape gap outside shape, for a mark round a part: each rounded corner grows by gap, a square corner stays square, and circles and capsules stay circles and capsules in their larger bounds.

comicOutsetShape(theme.shapes.small, theme.focus.gap)

Implementation

OutlinedBorder comicOutsetShape(OutlinedBorder shape, double gap) {
  if (shape is RoundedRectangleBorder) {
    Radius corner(Radius r) =>
        Radius.elliptical(r.x <= 0 ? 0 : r.x + gap, r.y <= 0 ? 0 : r.y + gap);
    final radius = shape.borderRadius.resolve(TextDirection.ltr);
    return shape.copyWith(
      borderRadius: shape.borderRadius is BorderRadiusDirectional
          ? BorderRadiusDirectional.only(
              topStart: corner(radius.topLeft),
              topEnd: corner(radius.topRight),
              bottomStart: corner(radius.bottomLeft),
              bottomEnd: corner(radius.bottomRight),
            )
          : BorderRadius.only(
              topLeft: corner(radius.topLeft),
              topRight: corner(radius.topRight),
              bottomLeft: corner(radius.bottomLeft),
              bottomRight: corner(radius.bottomRight),
            ),
    );
  }
  return shape;
}