animateTo method

void animateTo(
  1. double target, {
  2. SpringMotionPreset? preset,
  3. bool reducedMotion = false,
})

Implementation

void animateTo(
  double target, {
  SpringMotionPreset? preset,
  bool reducedMotion = false,
}) {
  if (!target.isFinite) {
    throw ArgumentError.value(target, 'target', 'must be finite');
  }
  if (reducedMotion) {
    jumpTo(target);
    return;
  }
  final simulation = SpringSimulation(
    springDescriptionFor(preset ?? this.preset),
    _controller.value,
    target,
    _controller.velocity,
  );
  _controller.animateWith(simulation).whenCompleteOrCancel(() {
    if (!_disposed) _controller.value = target;
  });
}