scrollToTopNoAnimate method

void scrollToTopNoAnimate()

Implementation

void scrollToTopNoAnimate() {
  if (_scrollController?.hasClients != true) return;
  final now = DateTime.now();
  const minInterval = 200; // ms
  if (now.difference(_lastScrollTime).inMilliseconds < minInterval) {
    debugPrint('SCROLL TO BOTTOM DEBOUNCED: Too soon after last scroll');
    return;
  }
  _lastScrollTime = now;

  try {
    if (!paginationConfig.reverseOrder) {
      // In reverse mode, "bottom" is actually the top (0.0)
      _scrollController!.jumpTo(
        0.0,
      );
    } else {
      // In chronological mode, bottom is maxScrollExtent
      _scrollController!.jumpTo(
        _scrollController!.position.maxScrollExtent,
      );
    }
  } catch (e) {
    // If we get an error (eg. because widget is disposing), just ignore it
    // This prevents errors when scrolling during state changes
    debugPrint('SCROLL TO BOTTOM ERROR: $e');
  }
}