فهرست منبع

Copy code on long press as well as on tap

vishnukvmd 2 سال پیش
والد
کامیت
2b5f349b2f
1فایلهای تغییر یافته به همراه10 افزوده شده و 3 حذف شده
  1. 10 3
      lib/ui/code_widget.dart

+ 10 - 3
lib/ui/code_widget.dart

@@ -79,9 +79,10 @@ class _CodeWidgetState extends State<CodeWidget> {
                     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<CodeWidget> {
     );
   }
 
+  void _copyToClipboard() {
+    FlutterClipboard.copy(_getTotp()).then(
+      (value) => showToast(context, "Copied to clipboard"),
+    );
+  }
+
   void _onDeletePressed(_) {
     final AlertDialog alert = AlertDialog(
       shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),