handleCut method Null safety

void handleCut(
  1. 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.userUpdateTextEditingValue(
    TextEditingValue(
      text: value.selection.textBefore(value.text)
          + value.selection.textAfter(value.text),
      selection: TextSelection.collapsed(
        offset: value.selection.start,
      ),
    ),
    SelectionChangedCause.toolBar,
  );
  delegate.bringIntoView(delegate.textEditingValue.selection.extent);
  delegate.hideToolbar();
}