detectClipboardApi static method

bool detectClipboardApi()

Determines if the clipboard API is available in the current browser.

bool isClipboardSupported = ClipboardWeb.detectClipboardApi();

Returns:

  • true if the clipboard API is available in the current browser,
  • false if the clipboard API is not available in the current browser.

Implementation

static bool detectClipboardApi() {
  final Clipboard clipboard = getClipboard();
  for (final String methodName in <String>['read', 'write']) {
    final dynamic method = js_util.getProperty(clipboard, methodName);
    if (method == null) {
      return false;
    }
  }

  return true;
}