comicInsetShape function
The concentric shape inside shape, with each corner reduced by inset.
Circles and capsules remain circles and capsules in their smaller bounds.
comicInsetShape(theme.shapes.medium, 3)
Implementation
OutlinedBorder comicInsetShape(OutlinedBorder shape, double inset) {
if (shape is RoundedRectangleBorder) {
Radius corner(Radius r) =>
Radius.elliptical(math.max(0, r.x - inset), math.max(0, r.y - inset));
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;
}