inset method

FrameArea inset({
  1. int left = 0,
  2. int top = 0,
  3. int right = 0,
  4. int bottom = 0,
})

Returns this area with the given edge insets removed.

Insets that consume more than the available size produce an empty area anchored within this area's bottom-right edge.

Implementation

FrameArea inset({int left = 0, int top = 0, int right = 0, int bottom = 0}) {
  if (left < 0 || top < 0 || right < 0 || bottom < 0) {
    throw ArgumentError('FrameArea insets must not be negative');
  }
  final insetX = left.clamp(0, width);
  final insetY = top.clamp(0, height);
  final insetWidth = width - left - right;
  final insetHeight = height - top - bottom;
  return FrameArea(
    x + insetX,
    y + insetY,
    insetWidth > 0 ? insetWidth : 0,
    insetHeight > 0 ? insetHeight : 0,
  );
}