'Flutter: InkWell vs GestureDetector: what is the difference?
I'm completely new to Flutter and found out about InkWell and GestureDetector. It seemed to me that they are almost the same. The official documentation doesn't provide any in-depth comparison between them.
What are the differences between
InkWellandGestureDetector?When to use which?
Solution 1:[1]
I will try to mention the functionality difference they have.
GestureDetector class is very broad. you can detect every type of interaction the user has with the screen or widget using it. it includes pinch, swipe, touch, plus custom gestures.
InkWell has a limited number of gestures to detect but it gives you ways to decorate the widget. you can decorate
colors: splashColor, focusColor, hoverColor...
border: borderRadius,customBorder, ...
hope this is helpful!
Solution 2:[2]
Visual Difference

Other answers are absolutely right. This is the visual representation.
Solution 3:[3]
The InkWell makes the whole area of the child as hotspot and receives user interaction easily. However, the GestureDetector does not make the whole area of the child as hotspot, like the padding areas aren't hotspots. Thus, using GestureDetector often leads to failed user interaction.
Solution 4:[4]
For me the important difference between them is: InkWell must have a Material widget as an ancestor, while GestureDetector does not need a Material widget as ancestor.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | biniyam112 |
| Solution 2 | MBK |
| Solution 3 | enarcee |
| Solution 4 | I Made Mudita |
