getClipboardData method

  1. @override
Future<Map<String, String>?> getClipboardData()
override

get clipboard data from the clipboard asynchronously.

Returns:

  • Future<Map<String, String>?>: a Map containing the clipboard data.
    • 'plainText': String containing the plain text from the clipboard.
    • 'htmlText': String containing the html text from the clipboard.

Implementation

@override
Future<Map<String, String>?> getClipboardData() async {
  /// Read raw clipboard text from the DOM.
  final ClipboardData? clipboardData = await Clipboard.getData(Clipboard.kTextPlain);
  if (clipboardData == null) {
    /// Return null if clipboard is empty or unsupported.
    return null;
  }
  return <String, String>{
    'plainText': clipboardData.text ?? '',
    'htmlText': '', // since htmlText is not supported, return empty string.
  };
}