createPath method

  1. @override
Path createPath(
  1. Offset offset,
  2. double size,
  3. Neighbors neighbors
)
override

Implementation

@override
Path createPath(Offset offset, double size, Neighbors neighbors) {
  Path path = Path();
  double corner = cornerFraction.coerceIn(0, .5) * size;

  if (!neighbors.hasAny()){
    path.addRRect(RRect.fromLTRBR(
        offset.dx, offset.dy,
        offset.dx + size, offset.dy + size,
        Radius.circular(corner))
    );
  } else {

    double topLeft =0;
    double topRight=0;
    double bottomLeft=0;
    double bottomRight=0;

    if (!neighbors.top && !neighbors.left) {
      topLeft = corner;
    }
    if (!neighbors.top && !neighbors.right) {
      topRight = corner;
    }
    if (!neighbors.bottom && !neighbors.left) {
      bottomLeft = corner;
    }
    if (!neighbors.bottom && !neighbors.right) {
      bottomRight = corner;
    }

    path.addRRect(RRect.fromLTRBAndCorners(
      offset.dx, offset.dy, offset.dx + size, offset.dy + size,
        topLeft: Radius.circular(topLeft),
        topRight: Radius.circular(topRight),
        bottomLeft: Radius.circular(bottomLeft),
        bottomRight: Radius.circular(bottomRight),
    ));
  }

  return path;
}