handleCopy method

void handleCopy (TextSelectionDelegate delegate)

Copy the current selection of the text field managed by the given delegate to the Clipboard. Then, move the cursor to the end of the text (collapsing the selection in the process), and hide the toolbar.

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

Implementation

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