getOuterPath method

  1. @override
Path getOuterPath(
  1. Rect rect, {
  2. TextDirection? textDirection,
})
override

Create a Path that describes the outer edge of the border.

This path must not cross the path given by getInnerPath for the same Rect.

To obtain a Path that describes the area of the border itself, set the Path.fillType of the returned object to PathFillType.evenOdd, and add to this object the path returned from getInnerPath (using Path.addPath).

The textDirection argument must be provided non-null if the border has a text direction dependency (for example if it is expressed in terms of "start" and "end" instead of "left" and "right"). It may be null if the border will not need the text direction to paint itself.

See also:

Implementation

@override
Path getOuterPath(Rect rect, {TextDirection? textDirection}) {
  double round = cornerRadius;
  return Path()
    ..moveTo(rect.left + rect.width / 2.0 - round, rect.top + round) // Top
    ..quadraticBezierTo(rect.left + rect.width / 2.0, rect.top, rect.left + rect.width / 2.0 + round,  rect.top + round)
    ..lineTo(rect.right - round, rect.top + rect.height / 2.0 - round) // Right
    ..quadraticBezierTo(rect.right,  rect.top + rect.height / 2.0, rect.right - round,  rect.top + rect.height / 2.0 + round)
    ..lineTo(rect.left + rect.width  / 2.0 + round, rect.bottom - round) // Bottom
    ..quadraticBezierTo(rect.left + rect.width  / 2.0,  rect.bottom, rect.left + rect.width / 2.0 - round, rect.bottom - round)
    ..lineTo(rect.left + round, rect.top + rect.height / 2.0 + round) // Left
    ..quadraticBezierTo(rect.left, rect.top + rect.height / 2.0, rect.left + round, rect.top + rect.height / 2.0 - round)
    ..close();
}