copyToClipboard function
Copies the specified text to the system clipboard.
Parameters:
text
(String
): The text to copy to the clipboard.
Returns:
Future<bool>
: A future that completes withtrue
if the copy operation succeeded, orfalse
if an error occurred.
Implementation
Future<bool> copyToClipboard(String text) async {
try {
await Clipboard.setData(ClipboardData(text: text));
return true;
} catch (e) {
return false;
}
}