handleSelectWord method Null safety
- SelectWordSelectionEvent event
protected">@protected
Selects a word in a selectable at the location SelectWordSelectionEvent.globalPosition.
Implementation
@protected
SelectionResult handleSelectWord(SelectWordSelectionEvent event) {
for (int index = 0; index < selectables.length; index += 1) {
final Rect localRect = Rect.fromLTWH(0, 0, selectables[index].size.width, selectables[index].size.height);
final Matrix4 transform = selectables[index].getTransformTo(null);
final Rect globalRect = MatrixUtils.transformRect(transform, localRect);
if (globalRect.contains(event.globalPosition)) {
final SelectionGeometry existingGeometry = selectables[index].value;
dispatchSelectionEventToChild(selectables[index], event);
if (selectables[index].value != existingGeometry) {
// Geometry has changed as a result of select word, need to clear the
// selection of other selectables to keep selection in sync.
selectables
.where((Selectable target) => target != selectables[index])
.forEach((Selectable target) => dispatchSelectionEventToChild(target, const ClearSelectionEvent()));
currentSelectionStartIndex = currentSelectionEndIndex = index;
}
return SelectionResult.end;
}
}
return SelectionResult.none;
}