Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get ripple effect in Gesture Detector

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?

like image 663
Ρπίηζε Κιηφφ Avatar asked Nov 15 '25 15:11

Ρπίηζε Κιηφφ


1 Answers

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'),
        ),
      ),
    );
like image 74
Risheek Mittal Avatar answered Nov 18 '25 06:11

Risheek Mittal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!