RoundedRectangle.fromRRect constructor

RoundedRectangle.fromRRect(
  1. RRect rrect
)

Constructs a RoundedRectangle from ui RRect.

All corners of the rrect must have the same circular radii.

Implementation

factory RoundedRectangle.fromRRect(RRect rrect) {
  final radius = rrect.brRadiusX;
  assert(
    rrect.blRadiusX == radius &&
        rrect.brRadiusX == radius &&
        rrect.tlRadiusX == radius &&
        rrect.trRadiusX == radius &&
        rrect.blRadiusY == radius &&
        rrect.brRadiusY == radius &&
        rrect.tlRadiusY == radius &&
        rrect.trRadiusY == radius,
    'Unequal radii in the $rrect',
  );
  return RoundedRectangle.fromLTRBR(
    rrect.left,
    rrect.top,
    rrect.right,
    rrect.bottom,
    radius,
  );
}