copyToClipboard static method
拷贝文本内容到剪切板
Implementation
static bool copyToClipboard(String text, {String? successMessage, BuildContext? context}) {
if (TextUtils.isNotEmpty(text)) {
Clipboard.setData(new ClipboardData(text: text));
if (context != null) {
ScaffoldMessenger.of(context).showSnackBar(new SnackBar(
duration: Duration(seconds: 1),
content: new Text(successMessage ?? "copy success")));
return true;
} else {
return false;
}
}
return false;
}