Skip to content

Instantly share code, notes, and snippets.

@bizz84
Last active September 9, 2024 11:14
Show Gist options
  • Save bizz84/0a57ad7afbe75353236943d30abf6cb0 to your computer and use it in GitHub Desktop.
Save bizz84/0a57ad7afbe75353236943d30abf6cb0 to your computer and use it in GitHub Desktop.
Custom TripleTapDetector widget using RawGestureDetector
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class TripleTapDetector extends StatelessWidget {
const TripleTapDetector({
super.key,
required this.child,
required this.onTripleTap,
});
final Widget child;
final VoidCallback onTripleTap;
@override
Widget build(BuildContext context) {
return RawGestureDetector(
gestures: {
SerialTapGestureRecognizer:
GestureRecognizerFactoryWithHandlers<SerialTapGestureRecognizer>(
() => SerialTapGestureRecognizer(),
(SerialTapGestureRecognizer instance) {
instance.onSerialTapDown = (SerialTapDownDetails details) {
if (details.count == 3) {
onTripleTap();
}
};
},
),
},
child: child,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment