Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

provide splash and highLight color for flutter GestureDetector

Tags:

flutter

dart

I have a GestureDetector in flutter which is responsible for detection of different user gesture. but my problem is that how can I provide splash and highLight color for that ?

like image 234
HamidNE Avatar asked Mar 03 '23 03:03

HamidNE


2 Answers

Use InkWell widget insteadof GestureDetector.

like image 57
N0000B Avatar answered May 07 '23 01:05

N0000B


You could use an InkWell as the child of your GestureDetector like this:

GestureDetector(
  onHorizontalDragEnd: (details) 
  {
  // 
  },
  child: InkWell(
    onTap: ()
    {
    // 
    },
    highlightColor: yourColor,
    splashColor: anotherColor,
  ),

This way you get the splash from the InkWell and can react to all the other gestures with the GestureDetector. The splash doesn't extend to the other gestures, so if the userinput leads to a another gesture (drag or whatever) then the splash is gone. Still this was good enough for me, the user can see there is a possible interaction with the ui-element. (Also use Inks instead of containers to not cover the splash.)

like image 38
SchmadenWTGGTTTGG Avatar answered May 07 '23 01:05

SchmadenWTGGTTTGG