tick method

  1. @override
bool tick(
  1. double delta,
  2. Duration elapsed
)
override

Called each time there is an update from the ticker on the AnimatedBackground

The implementation must return true if there is a need to repaint and false otherwise.

Implementation

@override
bool tick(double delta, Duration elapsed) {
  center = Offset.lerp(center, targetCenter, delta * 5.0);
  for (Star star in stars!) {
    star.position = Offset(
      star.targetPosition.dx / star.distance,
      star.targetPosition.dy / star.distance,
    );
    star.distance -= delta * 500;
    if (star.distance <= 0 ||
        star.position!.dx > size!.width ||
        star.position!.dy > size!.height) _initStar(star);
  }
  return true;
}