copyToClipboard function

Future<bool> copyToClipboard(
  1. String text
)

Copies the specified text to the system clipboard.

Parameters:

  • text (String): The text to copy to the clipboard.

Returns:

  • Future<bool>: A future that completes with true if the copy operation succeeded, or false if an error occurred.

Implementation

Future<bool> copyToClipboard(String text) async {
  try {
    await Clipboard.setData(ClipboardData(text: text));
    return true;
  } catch (e) {
    return false;
  }
}