fling method

Future<void> fling (Finder finder, Offset offset, double speed, { int pointer, Duration frameInterval: const Duration(milliseconds: 16), Offset initialOffset: Offset.zero, Duration initialOffsetDelay: const Duration(seconds: 1) })

Attempts a fling gesture starting from the center of the given widget, moving the given distance, reaching the given speed.

If the middle of the widget is not exposed, this might send events to another object.

This can pump frames. See flingFrom for a discussion of how the offset, velocity and frameInterval arguments affect this.

The speed is in pixels per second in the direction given by offset.

A fling is essentially a drag that ends at a particular speed. If you just want to drag and end without a fling, use drag.

The initialOffset argument, if non-zero, causes the pointer to first apply that offset, then pump a delay of initialOffsetDelay. This can be used to simulate a drag followed by a fling, including dragging in the opposite direction of the fling (e.g. dragging 200 pixels to the right, then fling to the left over 200 pixels, ending at the exact point that the drag started).

Implementation

Future<void> fling(Finder finder, Offset offset, double speed, {
  int pointer,
  Duration frameInterval = const Duration(milliseconds: 16),
  Offset initialOffset = Offset.zero,
  Duration initialOffsetDelay = const Duration(seconds: 1),
}) {
  return flingFrom(
    getCenter(finder),
    offset,
    speed,
    pointer: pointer,
    frameInterval: frameInterval,
    initialOffset: initialOffset,
    initialOffsetDelay: initialOffsetDelay,
  );
}