animateTo method

Future<void>? animateTo(
  1. String key,
  2. double offset, {
  3. required Duration duration,
  4. Curve curve = Curves.easeInOut,
})

Animates the scroll position to offset for the controller with key.

Returns a Future that completes when the animation finishes. Returns null if the controller doesn't exist or isn't attached.

Implementation

Future<void>? animateTo(
  String key,
  double offset, {
  required Duration duration,
  Curve curve = Curves.easeInOut,
}) {
  final controller = _controllers[key];
  if (controller == null || !controller.hasClients) return null;
  return controller.animateTo(offset, duration: duration, curve: curve);
}