ensureChildUpdated method
- Selectable selectable
override
Ensures the selectable
child has received the most up to date selection events.
This method is called when:
- A new Selectable is added to the delegate, and its screen location falls into the previous selection.
- Before a SelectionEvent of type SelectionEventType.startEdgeUpdate, SelectionEventType.endEdgeUpdate, SelectionEventType.granularlyExtendSelection, or SelectionEventType.directionallyExtendSelection is dispatched to a Selectable child.
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);
}
}