toggle method
Toggles the animation back and forth.
If a forward value is passed, it determines the animation's direction.
If the value of forward matches isForwardOrCompleted, this method
returns the existing TickerFuture instead of cancelling it.
This also means that the animation's speed will remain unchanged,
even if maintainSpeed is false.
If forward is null, then toggle() will switch directions
each time it's called.
Implementation
TickerFuture toggle({bool? forward}) {
if (forward == isForwardOrCompleted && _ticker!.isActive) {
return _currentAnimation;
}
forward ??= !isForwardOrCompleted;
return animateTo(forward ? 1.0 : 0.0);
}