copySelection method

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

Copy current selection to Clipboard.

If cause is SelectionChangedCause.toolbar, the position of bringIntoView to selection will be called and hide toolbar.

Implementation

@override
void copySelection(SelectionChangedCause cause) {
  if (cause == SelectionChangedCause.toolbar) {
    bringIntoView(textEditingValue.selection.extent);
    hideToolbar(false);

    switch (defaultTargetPlatform) {
      case TargetPlatform.iOS:
        break;
      case TargetPlatform.macOS:
      case TargetPlatform.android:
      case TargetPlatform.fuchsia:
      case TargetPlatform.linux:
      case TargetPlatform.windows:
      // Collapse the selection and hide the toolbar and handles.
        userUpdateTextEditingValue(
          TextEditingValue(
            text: textEditingValue.text,
            selection: TextSelection.collapsed(offset: textEditingValue.selection.end),
          ),
          SelectionChangedCause.toolbar,
        );
        break;
    }
  }
}