Forráskód Böngészése

imageButton防双击添加

xiaohui 2 hete
szülő
commit
fd0f31a129
1 módosított fájl, 8 hozzáadás és 1 törlés
  1. 8 1
      lib/components/imageButton.dart

+ 8 - 1
lib/components/imageButton.dart

@@ -1,4 +1,5 @@
 
+import 'package:faqim_mobile/components/clickUtil.dart';
 import 'package:flutter/material.dart';
 
 
@@ -29,7 +30,13 @@ class ImageButton extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return GestureDetector(
-      onTap: onTap,
+      onTap: () {
+        // 防止快速连击重复触发。
+        if (ClickUtil.isFastClick()) {
+          return;
+        }
+        onTap?.call();
+      },
       child: Opacity(
         opacity: onTap == null ? 0.5 : 1.0,
         child: Container(