scrollToTop method

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

Scrolls to the top of the list

Implementation

Future<void> scrollToTop({
  Duration duration = const Duration(milliseconds: 300),
  Curve curve = Curves.ease,
}) async {
  if (!isAttached || _isDisposed) return;

  try {
    await _scrollController!.animateTo(
      0.0,
      duration: duration,
      curve: curve,
    );
  } catch (e, stackTrace) {
    _callbacks?.onError?.call('Failed to scroll to top of list $_listIndex: $e', stackTrace);
  }
}