copyToClipboard static method

bool copyToClipboard(
  1. String text, {
  2. String? successMessage,
  3. BuildContext? context,
  4. Function? successCallback,
})

拷贝文本内容到剪切板

Implementation

static bool copyToClipboard(String text,
    {String? successMessage,
    BuildContext? context,
    Function? successCallback}) {
  if (TextUtils.isNotEmpty(text)) {
    Clipboard.setData(ClipboardData(text: text));
    if (context != null) {
      if (successCallback != null) {
        successCallback();
      }
      return true;
    } else {
      return false;
    }
  }
  return false;
}