How to get ripple effect in Gesture Detector

4.2k Views Asked by At

I want to use the function LongPressDown which also gives LongPressDownDetails of GestureDetector but sadly, Gesture Detector comes without the ripple touch effect. So if I choose to use InkWell it doesn't have the LongPressDownDetails.

So my question is, how can I get the ripple effect of InkWell with the features of GestureDetector?

1

There are 1 best solutions below

6
Risheek Mittal On BEST ANSWER

It's pretty straightforward, just add an Inkwell over the GestureDetector and you'll be good to go (no need to write anything in the onTap).

return InkWell(
      onTap: () {},
      child: GestureDetector(
        onLongPress: (){
          ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
          content: Text('Tap'),
        ));
        }
        ,
        child: const Padding(
          padding: EdgeInsets.all(12.0),
          child: Text('Flat Button'),
        ),
      ),
    );