Search code examples
buttonflutterdartonclicklistener

How can I listen for second click in gesture detector in Flutter?


I want to create a button with a gesture detector, and I want to listen for the second click from the user on this button.

I want to do something like this:

GestureDetector(
  onSecondTap: () {
    // My code
  }
  child: FlatButton(),
), // GestureDetector

Solution

  • GestureDetector has the onDoubleTap listener. This will be trigger if the user double clicks the widget within certain amount of time.

    GestureDetector(
        onDoubleTap: () {
            // Your code here
        }
    ...