scrollToTop method

Future<void> scrollToTop({
  1. Duration duration = const Duration(milliseconds: 300),
  2. Curve curve = Curves.easeInOut,
})

Scrolls the ScrollController to the top (offset 0) with smooth animation.

duration specifies the duration of the scroll animation. curve defines the curve for the animation (defaults to Curves.easeInOut).

Implementation

Future<void> scrollToTop({
  Duration duration = const Duration(milliseconds: 300),
  Curve curve = Curves.easeInOut,
}) {
  return animateToPosition(0.0, duration: duration, curve: curve);
}