progress property

  1. @override
double get progress
override

The current progress of the effect, a value between 0 and 1.

Implementation

@override
double get progress {
  // Assume zigzag's period is 4 units of length. Within that period, there
  // are 3 linear segments: at first it's y = x, for 0 ≤ x ≤ 1, then it's
  // y = -x + 2, for 1 ≤ x ≤ 3, and finally it's y = x + (-4), for 3 ≤ x ≤ 4.
  final x = timer / _quarterPeriod;
  return switch (x) {
    <= 1 => x,
    >= 3 => x - 4,
    _ => 2 - x,
  };
}