After copying the text of the SelectableText widget, I want to display a toast message. But I don't see an option to do that. What should I do?
Asked
Active
Viewed 742 times
1
-
try onSelectionChanged on SelectableText Widget – PRATHIV May 01 '22 at 07:27
2 Answers
0
following works for me, shows a toast message after copying data to device clipboard:
Clipboard.setData(ClipboardData(
text: global_variables.myQRpartnerToStayInTouchWithUid))
.then(
(_) => ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text(
'Copied to clipboard',
textAlign: TextAlign.right,
))));
my code based on answer at https://stackoverflow.com/a/68321291/3120387

tmr
- 1,500
- 15
- 22
-1
Clipboard.setData(ClipboardData(text: "message"))
.then((_) {
ScaffoldMessenger.of(context).showSnackBar(flutterToast("Copy,false"));
});
// flutterToast is common widget like this
// packages fluttertoast latest version recommended
flutterToast(String massage, bool set) {
Fluttertoast.showToast(
msg: massage,
toastLength: Toast.LENGTH_SHORT,
gravity: set ? ToastGravity.TOP : ToastGravity.BOTTOM,
timeInSecForIosWeb: 1,
backgroundColor: set ? Colors.red : Colors.green,
textColor: Colors.white,
fontSize: 16.0);
}

make
- 1