shareSelection method

Future<void> shareSelection(
  1. SelectionChangedCause cause
)

Launch the share interface for the current selection, as in the "Share" edit menu button on iOS.

Currently this is only implemented for iOS.

When 'obscureText' is true or the selection is empty, this function will not do anything

Implementation

Future<void> shareSelection(SelectionChangedCause cause) async {
  final text = textEditingValue.selection.textInside(textEditingValue.text);
  if (text.isNotEmpty) {
    await SystemChannels.platform.invokeMethod(
      'Share.invoke',
      text,
    );
  }
}