recede method
Similar to advance(), but makes the effect controller move back in time.
If the supplied amount of time dt would push the effect past its
starting point, then the effect stops at the start and the "leftover"
portion of dt is returned.
Implementation
@override
double recede(double dt) {
if (t <= 0) {
return dt;
}
final t0 = t;
t -= dt;
if (alternate && t < _duration / 2 && t0 >= _duration / 2) {
final tInBackward = t0 - _duration / 2;
final tInForward = _duration / 2 - t;
for (final effect in effects) {
if (tInBackward > 0) {
effect.recede(tInBackward);
}
effect.advance(tInForward);
}
} else if (!alternate || t >= _duration / 2) {
// Backward
for (final effect in effects) {
final effectDuration = effect.controller.duration ?? 0;
final timeInAlt = t0 - _duration / 2;
if (timeInAlt < effectDuration) {
final t1 = max(t - _duration / 2, 0.0);
effect.recede(timeInAlt - t1);
}
}
} else {
// Forward
for (final effect in effects) {
final effectDuration = effect.controller.duration ?? 0;
if (t0 < effectDuration) {
final t1 = max(t, 0.0);
effect.recede(t0 - t1);
}
}
}
if (t <= 0) {
final surplus = -t;
t = 0;
return surplus;
}
return 0;
}