onSetSelection property

SetSelectionHandler onSetSelection

The handler for SemanticsAction.setSelection.

This handler is invoked when the user either wants to change the currently selected text in a text field or change the position of the cursor.

TalkBack users can trigger this handler by selecting "Move cursor to beginning/end" or "Select all" from the local context menu.


SetSelectionHandler get onSetSelection => _onSetSelection;
void onSetSelection= (SetSelectionHandler value)


set onSetSelection(SetSelectionHandler value) {
  assert(value != null);
  _addAction(SemanticsAction.setSelection, (dynamic args) {
    assert(args != null && args is Map);
    final Map<String, int> selection = args.cast<String, int>();
    assert(selection != null && selection['base'] != null && selection['extent'] != null);
      baseOffset: selection['base'],
      extentOffset: selection['extent'],
  _onSetSelection = value;