getRoundedCorners method

Path getRoundedCorners(
  1. Size size
)

Implementation

Path getRoundedCorners(Size size) {

  var topLeftPixelsFromTop = (size.height * topLeftPercentOfHeight) / 100.0;
  var bottomLeftPixelsFromTop = (size.height * bottomLeftPercentOfHeight) / 100.0;
  var topRightPixelsFromTop = (size.height * topRightPercentOfHeight) / 100.0;
  var bottomRightPixelsFromTop = (size.height * bottomRightPercentOfHeight) / 100.0;

  var path = Path();
  path.moveTo(0.0, topLeftPixelsFromTop + radius);
  path.lineTo(0.0, bottomLeftPixelsFromTop - radius);
  path.quadraticBezierTo(0.0, bottomLeftPixelsFromTop, radius, bottomLeftPixelsFromTop);
  path.lineTo(size.width - radius, bottomRightPixelsFromTop);
  path.quadraticBezierTo(size.width, bottomRightPixelsFromTop, size.width, bottomRightPixelsFromTop - radius);
  path.lineTo(size.width, topRightPixelsFromTop + radius);
  path.quadraticBezierTo(size.width, topRightPixelsFromTop, size.width - radius, topRightPixelsFromTop);
  path.lineTo(radius, topLeftPixelsFromTop);//was 20, 5
  path.quadraticBezierTo(0.0, topLeftPixelsFromTop, 0.0, topLeftPixelsFromTop + radius);
  return path;
}