handleCut method

void handleCut (TextSelectionDelegate delegate)

Copy the current selection of the text field managed by the given delegate to the Clipboard. Then, remove the selected text from the text field and hide the toolbar.

This is called by subclasses when their cut affordance is activated by the user.

Implementation

void handleCut(TextSelectionDelegate delegate) {
  final TextEditingValue value = delegate.textEditingValue;
  Clipboard.setData(ClipboardData(
    text: value.selection.textInside(value.text),
  ));
  delegate.textEditingValue = TextEditingValue(
    text: value.selection.textBefore(value.text)
        + value.selection.textAfter(value.text),
    selection: TextSelection.collapsed(
      offset: value.selection.start
    ),
  );
  delegate.bringIntoView(delegate.textEditingValue.selection.extent);
  delegate.hideToolbar();
}