scrollByPixels method

  1. @override
Future<bool> scrollByPixels(
  1. double pixels
)
override

Scroll by an exact pixels delta (positive = forward / toward end, negative = backward / toward start).

Implementation

@override
Future<bool> scrollByPixels(double pixels) async {
  if (!scrollPosition.hasContentDimensions) return false;
  final target = (scrollPosition.pixels + pixels)
      .clamp(scrollPosition.minScrollExtent, scrollPosition.maxScrollExtent);
  if ((target - scrollPosition.pixels).abs() < 1) return false;
  await scrollPosition.animateTo(target, duration: duration, curve: curve);
  await _awaitFrameSettle();
  return true;
}