ensureChildUpdated method

  1. @override
void ensureChildUpdated(
  1. Selectable selectable
)
override

Ensures the Selectable child has received up to date selection event.

This method is called when a new Selectable is added to the delegate, and its screen location falls into the previous selection.

Subclasses are responsible for updating the selection of this newly added Selectable.

Implementation

@override
void ensureChildUpdated(Selectable selectable) {
  if (_lastEndEdgeUpdateGlobalPosition != null &&
      _hasReceivedEndEvent.add(selectable)) {
    final SelectionEdgeUpdateEvent synthesizedEvent =
        SelectionEdgeUpdateEvent.forEnd(
      globalPosition: _lastEndEdgeUpdateGlobalPosition!,
    );
    if (currentSelectionEndIndex == -1) {
      handleSelectionEdgeUpdate(synthesizedEvent);
    }
    selectable.dispatchSelectionEvent(synthesizedEvent);
  }
  if (_lastStartEdgeUpdateGlobalPosition != null &&
      _hasReceivedStartEvent.add(selectable)) {
    final SelectionEdgeUpdateEvent synthesizedEvent =
        SelectionEdgeUpdateEvent.forStart(
      globalPosition: _lastStartEdgeUpdateGlobalPosition!,
    );
    if (currentSelectionStartIndex == -1) {
      handleSelectionEdgeUpdate(synthesizedEvent);
    }
    selectable.dispatchSelectionEvent(synthesizedEvent);
  }
}