fluttergesture-recognition

InkWell effect starts delayed if using onDoubleTap; want to trigger that as soon as the widget gets touched


If you are using onTap & onDoubleTap side by side with an InkWell, then a single tap gets delayed (300ms). I know the time is needed for the recognition of a double tap but also the effect is delayed, and that's a bad user interaction feeling.

What I've tried: I found out, that the InkWell effect is startet as soon as any tap event callback gets called. If I use onTap alone, the callback and the effect is started instantly on the first touch; if I use onTap and onDoubleTap, the effect gets delayed.

I also tried using onTapDown, but this also gets delayed (possilbe Bug?)

child: InkWell(
  onTap: () { print("Tap"); },                // gets delayed 300ms
  onDoubleTap: () { print("Double Tap"); }, 
  onTapDown: (x) { print("Tap Down"); }       // gets delayed 300ms
}

So my question: Is it anyway possible to change the InkWell (GestureDetector) to start the effect instantly. I think the solution could be, to change the onTapDown behavior; this should be called immediately if the user touches the widget.


Solution

  • I've now found a simple solution. I am only using the onTap function of the InkWell and have written the onDoubleTap algorithm my self. So the splash effect runs immediately because the original onDoubleTap isn't used. The tap function itself gets delayed (as it also would have been by using the original onDoubleTap function).

    Pup.dev package I've written a pub.dev package called InkWellSplash. Additional to the splash feature, you can now adjust the maximal time between two taps to recognize a double tap.

    I'm pretty sure this package comes in handy and is useful for several developer

    Links

    Pub.dev - InklWellSplash

    GitHub - InkWellSplash

    Interactive Example