draw method

void draw(
  1. Canvas canvas,
  2. double space,
  3. double size,
  4. double radius,
)
override

Implementation

void draw(Canvas canvas, double space, double size, double radius) {
  double progress = page - index;
  double distance = size + space;
  double start = index * (size + space);

  if (progress > 0.5) {
    double right = start + size + distance;
    //progress=>0.5-1.0
    //left:0.0=>distance

    double left = index * distance + distance * (progress - 0.5) * 2;
    canvas.drawRRect(
        new RRect.fromLTRBR(
            left, 0.0, right, size, new Radius.circular(radius)),
        _paint);
  } else {
    double right = start + size + distance * progress * 2;

    canvas.drawRRect(
        new RRect.fromLTRBR(
            start, 0.0, right, size, new Radius.circular(radius)),
        _paint);
  }
}