findMobileBaseDragHandle static method

Finder findMobileBaseDragHandle([
  1. Finder? superEditorFinder
])

Finds the base drag handle for a mobile SuperEditor.

Keep in mind that the base handle is the handle at the beginning of a selection. The beginning of a selection might appear on the left side or right side of a selection, depending on the direction that the user dragged to select content.

Implementation

static Finder findMobileBaseDragHandle([Finder? superEditorFinder]) {
  final selection = findDocumentSelection(superEditorFinder);
  expect(selection, isNotNull,
      reason: "Tried to find the mobile handle for the selection base, but the selection is null.");

  if (selection!.isCollapsed) {
    // When the selection is collapsed, the base and extent are the same. The choice is irrelevant.
    return findMobileDownstreamDragHandle(superEditorFinder);
  }

  if (selection.hasDownstreamAffinity(findDocument(superEditorFinder)!)) {
    return findMobileUpstreamDragHandle(superEditorFinder);
  } else {
    return findMobileDownstreamDragHandle(superEditorFinder);
  }
}