toRRect method

  1. @override
RRect toRRect(
  1. Rect rect
)
override

Creates an RRect from the current border radius and a Rect.

If any of the radii have negative values in x or y, those values will be clamped to zero in order to produce a valid RRect.

Implementation

@override
RRect toRRect(Rect rect) {
  final dimension = math.min(rect.width, rect.height);
  if (_min <= dimension) {
    return super.toRRect(rect);
  }

  final t = 1 - dimension / _min;
  return RRect.fromRectAndCorners(
    rect,
    topLeft: Radius.elliptical(topLeft.x * t, topLeft.y * t),
    topRight: Radius.elliptical(topRight.x * t, topRight.y * t),
    bottomLeft: Radius.elliptical(bottomLeft.x * t, bottomLeft.y * t),
    bottomRight: Radius.elliptical(bottomRight.x * t, bottomRight.y * t),
  );
}