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) {
  if (_rectList == null) return false;
  for (Rectangle? rect in _rectList!) {
    rect!.t = math.min(rect.t + delta * 0.5, 1.0);

    rect.color = HSVColor.lerp(rect.initialColor, rect.fadeTo, rect.t);
    if (rect.fadeTo!.toColor().value == rect.color!.toColor().value) {
      rect.initialColor = rect.fadeTo;
      rect.fadeTo = randomColor();
      rect.t = 0.0;
    }
  }
  return true;
}