getClipboardText static method

Future<String?> getClipboardText()

Retrieves the current text from the clipboard.

Implementation

static Future<String?> getClipboardText() async {
  try {
    final clipboardData = await Clipboard.getData(Clipboard.kTextPlain);
    return clipboardData?.text;
  } catch (e) {
    print("Failed to get clipboard text: $e");
    return null;
  }
}