-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(raffle): Extra logging & error handling
- Loading branch information
1 parent
40e08ab
commit f00cbd7
Showing
9 changed files
with
135 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'dart:async'; | ||
|
||
class TripleTapDetector extends StatefulWidget { | ||
final Widget child; | ||
final VoidCallback onTripleTap; | ||
final Duration timeWindow; | ||
|
||
const TripleTapDetector({ | ||
required this.child, | ||
required this.onTripleTap, | ||
this.timeWindow = const Duration(seconds: 1), | ||
super.key, | ||
}); | ||
|
||
@override | ||
State<TripleTapDetector> createState() => _TripleTapDetectorState(); | ||
} | ||
|
||
class _TripleTapDetectorState extends State<TripleTapDetector> { | ||
int tapCount = 0; | ||
Timer? tapTimer; | ||
|
||
@override | ||
void dispose() { | ||
tapTimer?.cancel(); | ||
super.dispose(); | ||
} | ||
|
||
void handleTap() { | ||
setState(() { | ||
tapCount++; | ||
if (tapCount == 3) { | ||
widget.onTripleTap(); | ||
tapCount = 0; | ||
} | ||
|
||
tapTimer?.cancel(); | ||
tapTimer = Timer(widget.timeWindow, () { | ||
setState(() { | ||
tapCount = 0; | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GestureDetector( | ||
onTap: handleTap, | ||
child: widget.child, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters