scrollToPositionIfNotAtTop method

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

Scrolls to the given position only if the position is not at the top already.

Implementation

Future<void> scrollToPositionIfNotAtTop(
  double offset, {
  Duration duration = const Duration(milliseconds: 300),
  Curve curve = Curves.easeInOut,
}) {
  if (!isAtTop) {
    return animateToPosition(offset, duration: duration, curve: curve);
  }
  return Future.value();
}