dragGestureForPosition method

SingleDrag? dragGestureForPosition({
  1. required BuildContext context,
  2. required Offset position,
  3. required int pointer,
})

Implementation

SingleDrag? dragGestureForPosition({
  required BuildContext context,
  required Offset position,
  required int pointer,
}) {
  if (LongPressSession.active) {
    return null;
  }
  return LongPressSession.run(() {
    final previewUpdateNotifier = ValueNotifier<WidgetSnapshot?>(null);
    final session = _FakeDragSession();
    LongPressSession.onCleanup(session._dispose);

    final dragConfiguration =
        _dragContext.delegate?.getConfigurationForDragRequest(
      location: position,
      session: session,
    );
    final menuConfiguration = _menuContext.delegate?.getMenuConfiguration(
      MobileMenuConfigurationRequest(
        configurationId: _nextMenuConfigurationId++,
        location: position,
        previewImageSetter: (image) {
          previewUpdateNotifier.value = image;
        },
      ),
    );
    if (dragConfiguration == null && menuConfiguration == null) {
      return null;
    }
    final dragFuture = _dragForConfigurationFutures(
      dragConfiguration: dragConfiguration,
      menuConfiguration: menuConfiguration,
      dragSession: session,
      pointer: pointer,
      context: context,
      position: position,
      previewUpdateListenable: previewUpdateNotifier,
    );
    return DelayedDrag(LongPressSession.extend(() => dragFuture));
  });
}