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 (!_hasSinglePosition) return false;
  final pos = controller.position;
  final target =
      (pos.pixels + pixels).clamp(pos.minScrollExtent, pos.maxScrollExtent);
  if ((target - pos.pixels).abs() < 1) return false;
  await controller.animateTo(target, duration: duration, curve: curve);
  await _awaitFrameSettle();
  return true;
}