cutSelection method Null safety

  1. @override
void cutSelection(
  1. SelectionChangedCause cause
)
override

Cut current selection to Clipboard.

Implementation

@override
void cutSelection(SelectionChangedCause cause) {
  if (widget.readOnly || widget.obscureText) {
    return;
  }
  final TextSelection selection = textEditingValue.selection;
  final String text = textEditingValue.text;
  assert(selection != null);
  if (selection.isCollapsed) {
    return;
  }
  Clipboard.setData(ClipboardData(text: selection.textInside(text)));
  _replaceText(ReplaceTextIntent(textEditingValue, '', selection, cause));
  if (cause == SelectionChangedCause.toolbar) {
    // Schedule a call to bringIntoView() after renderEditable updates.
    SchedulerBinding.instance.addPostFrameCallback((_) {
      if (mounted) {
        bringIntoView(textEditingValue.selection.extent);
      }
    });
    hideToolbar();
  }
  _clipboardStatus?.update();
}