animateTo method
Animate to a target progress value using AnimationController if available
Implementation
Future<void> animateTo(
double target, {
Duration duration = const Duration(milliseconds: 300),
Curve curve = Curves.easeInOut,
}) async {
final end = target.clamp(0.0, 1.0);
if (_controller != null && _tickerProvider != null) {
// Use AnimationController (more efficient)
_controller!.duration = duration;
_animation = CurvedAnimation(
parent: _controller!,
curve: curve,
);
_animation!.removeListener(_onAnimationUpdate);
_animation!.addListener(_onAnimationUpdate);
final startProgress = _progress.value;
_controller!.value = startProgress;
await _controller!.animateTo(end);
} else {
// Fallback to polling (for backwards compatibility)
await _animateToPolling(end, duration: duration, curve: curve);
}
}