RectShape constructor

RectShape({
  1. BorderRadiusGeometry borderRadius = BorderRadius.zero,
})

RectShape constructor.

Implementation

RectShape({
  this.borderRadius = BorderRadius.zero,
}) : super(
        path: (size) {
          var usedSize = size;
          // if no offset is provided use the center of the widget.
          var usedOffset = Offset(
            (size.width - usedSize.width) / 2,
            (size.height - usedSize.height) / 2,
          );
          BorderRadius rr = borderRadius.resolve(TextDirection.rtl);
          var path = Path()
            ..addRRect(
              RRect.fromRectAndCorners(
                Rect.fromLTWH(
                  usedOffset.dx,
                  usedOffset.dy,
                  usedSize.width,
                  usedSize.height,
                ),
                topLeft: rr.topLeft,
                topRight: rr.topRight,
                bottomLeft: rr.bottomLeft,
                bottomRight: rr.bottomRight,
              ),
            );
          path.close();

          return path;
        },
      );