From 2b5f349b2fd9efd3051ec4b4f4b7860c2d3a7adc Mon Sep 17 00:00:00 2001 From: vishnukvmd Date: Mon, 14 Nov 2022 20:30:15 +0530 Subject: [PATCH] Copy code on long press as well as on tap --- lib/ui/code_widget.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ui/code_widget.dart b/lib/ui/code_widget.dart index 921be06fbc..13c81ffd7c 100644 --- a/lib/ui/code_widget.dart +++ b/lib/ui/code_widget.dart @@ -79,9 +79,10 @@ class _CodeWidgetState extends State { borderRadius: BorderRadius.circular(10), ), onTap: () { - FlutterClipboard.copy(_getTotp()).then( - (value) => showToast(context, "Copied to clipboard"), - ); + _copyToClipboard(); + }, + onLongPress: () { + _copyToClipboard(); }, child: SizedBox( child: Column( @@ -155,6 +156,12 @@ class _CodeWidgetState extends State { ); } + void _copyToClipboard() { + FlutterClipboard.copy(_getTotp()).then( + (value) => showToast(context, "Copied to clipboard"), + ); + } + void _onDeletePressed(_) { final AlertDialog alert = AlertDialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),