pullToRefresh method

Future<void> pullToRefresh({
  1. Offset from = const Offset(0.5, 0.5),
  2. Offset to = const Offset(0.5, 0.9),
  3. int steps = 50,
})

Simulates pull-to-refresh gesture.

It swipes from from to to with the specified number of steps.

from and to must be in the inclusive 0-1 range.

steps controls the speed and smoothness of the swipe. More steps equals slower gesture.

The default values simulate a typical pull-to-refresh gesture:

  • from: Center of the screen (0.5, 0.5)
  • to: Bottom center of the screen (0.5, 0.9)
  • steps: 50 You can override these if scrollable content is not at the center of the screen or if the direction of the gesture is different.

Implementation

Future<void> pullToRefresh({
  Offset from = const Offset(0.5, 0.5),
  Offset to = const Offset(0.5, 0.9),
  int steps = 50,
}) => _platform.action.mobile(
  android: () =>
      _platform.android.pullToRefresh(from: from, to: to, steps: steps),
  ios: () => _platform.ios.pullToRefresh(from: from, to: to),
);