All 7 Flutter Gestures & Touch Handling questions
More in Flutter Gestures & Touch Handling
Advertisement
Flutter › Flutter Gestures & Touch Handling

What is the difference between GestureDetector and InkWell, and when would you specifically choose InkWell instead, particularly for a Material Design styled interactive element?

Beginner

Answer

While GestureDetector purely detects gesture input without providing any visual feedback of its own whatsoever, InkWell additionally provides that same underlying gesture detection capability while also displaying Material Design's own characteristic visual ripple effect that appears to genuinely emanate outward from the exact specific point where a user actually tapped, giving helpful visual confirmation that their tap was successfully registered, and InkWell is generally the genuinely more appropriate choice specifically when you want your particular custom interactive element to visually feel consistent with the rest of a typical Material Design styled interface.
InkWell(
  onTap: () => selectItem(),
  child: Padding(
    padding: EdgeInsets.all(16),
    child: Text('Select this item'),
  ),
)
Real-world example A settings screen wraps each individual list item with InkWell rather than a plain GestureDetector, providing the exact same familiar Material ripple visual feedback a user would already genuinely expect from tapping any other typical Material Design styled list item elsewhere in the app.

Common follow-ups: Does InkWell actually require a Material widget to be present somewhere further up in the widget tree in order to properly work?;How do you properly customize InkWell's own specific ripple color?