Want to disable onTap for a while in gesture detector in flutter? Use the following example code to disable onTap for a while in gesture detector in flutter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
bool _condition = true; //... GestureDetector( onTap: _condition ? () { // making it false when onTap() is pressed and after 1 second we'll make it true setState(() => _condition = false); Timer(Duration(seconds: 1), () => setState(() => _condition = true)); // your implementation } : null, // disable onTap if condition is false child: Icon(Icons.content_copy,), ), |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.