copyToClipboard function

Future<bool?> copyToClipboard({
  1. required String string,
})

Copy string to ClipboardData and show a Fluttertoast for the user

Implementation

Future<bool?> copyToClipboard({required String string}) async {
  await Clipboard.setData(ClipboardData(text: string));
  return Fluttertoast.showToast(
    msg: 'Copied to clipboard',
    toastLength: Toast.LENGTH_SHORT,
    backgroundColor: Colors.black,
    fontSize: 18,
    textColor: Colors.white,
  );
}