getRoundedShield method

Path getRoundedShield(
  1. Size size
)

Implementation

Path getRoundedShield(Size size) {
  var topLeftPixelsFromTop = (size.height * topLeftPercentOfHeight) / 100.0;
  var topRightPixelsFromTop = (size.height * topRightPercentOfHeight) / 100.0;

  //100% is default and indicates a default rounding is desired since otherwise it creates a rectangle (which seems broken)
  var botLeftPct = bottomLeftPercentOfHeight == 100 ? 60 : bottomLeftPercentOfHeight;
  var botRightPct = bottomRightPercentOfHeight == 100 ? 60 : bottomRightPercentOfHeight;
  var bottomLeftPixelsFromTop = (size.height * botLeftPct) / 100.0;
  var bottomRightPixelsFromTop = (size.height * botRightPct) / 100.0;

  Path path = Path();
  path.moveTo(0.0, bottomLeftPixelsFromTop);
  path.arcToPoint(Offset(size.width, bottomRightPixelsFromTop),
      radius: Radius.elliptical(size.width/2, size.height - bottomRightPixelsFromTop),
      clockwise: false
  );
  path.lineTo(size.width, topRightPixelsFromTop);
  path.lineTo(0.0, topLeftPixelsFromTop);
  path.close();
  return path;
}