copyClipboard function

dynamic copyClipboard(
  1. BuildContext context,
  2. String? value
)

复制到粘贴板

Implementation

copyClipboard(BuildContext context, String? value) {
  var snackBar = SnackBar(
      backgroundColor: Colors.blueAccent,
      content: Text(
        '$value\n\n copy success to clipboard',
        style: TextStyle(color: Theme.of(context).textTheme.bodyLarge?.color),
      ));
  ScaffoldMessenger.of(context).showSnackBar(snackBar);
  Clipboard.setData(ClipboardData(text: value ?? 'null'));
}