onDragEnd method
The drag event has ended.
This event will be delivered to the component(s) that captured the initial onDragStart, even if the point of touch moves outside of the boundaries of the component.
Implementation
@override
bool onDragEnd(DragEndEvent event) {
super.onDragEnd(event);
final now = DateTime.now();
_dragSamples.removeWhere(
(sample) => now.difference(sample.time) > _sampleWindow,
);
if (_dragSamples.length >= 2) {
final oldest = _dragSamples.first;
final newest = _dragSamples.last;
final dy = newest.offset - oldest.offset;
final dt = newest.time.difference(oldest.time).inMilliseconds / 1000;
if (dt > 0) {
_scrollVelocity = dy / dt;
}
}
_dragSamples.clear();
return true;
}