shapeBorderFor function

OutlinedBorder shapeBorderFor(
  1. GlassShape shape, {
  2. double concentricRadius = 16,
})

Maps a GlassShape onto the Flutter shape that matches what iOS draws.

Returns OutlinedBorder rather than ShapeBorder so callers can add a side with copyWith — which is how the Increase Contrast outline is drawn.

GlassShape.superellipse and GlassShape.concentric use RoundedSuperellipseBorder — Flutter's implementation of the Apple squircle. Using a plain rounded rectangle here is the single most common reason hand-rolled glass looks subtly wrong next to system UI.

Implementation

OutlinedBorder shapeBorderFor(
  GlassShape shape, {
  double concentricRadius = 16,
}) {
  return switch (shape) {
    _ when shape == GlassShape.capsule => const StadiumBorder(),
    _ when shape == GlassShape.circle => const CircleBorder(),
    _ => _fromMap(shape.toMap(), concentricRadius),
  };
}