What is the visual difference between GestureDetector and InkWell?
InkWell provides the Material Design ink ripple animation on tap. GestureDetector detects gestures but has no built-in visual feedback.
Detect taps, swipes, long presses and add ripple effects
Passing the Quiz & Exercises is mandatory to earn FX and proceed. If you fail, try again to gain the required FX, then the Proceed button will become available.
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
Flutter provides two primary ways to detect touch gestures:
1// ── GestureDetector ──2GestureDetector(3onTap: () => print('Tapped!'),4onDoubleTap: () => print('Double tapped!'),5onLongPress: () => print('Long pressed!'),6onHorizontalDragEnd: (details) {7if (details.velocity.pixelsPerSecond.dx > 0) {8print('Swiped right');9}10},11child: Container(12width: 100,13height: 100,14color: Colors.blue,15child: const Center(child: Text('Tap me')),16),17)
1// ── InkWell - Material ripple effect ──2InkWell(3onTap: () => print('Tapped with ripple!'),4onLongPress: () => print('Long pressed!'),5borderRadius: BorderRadius.circular(12), // clips the ripple6child: Container(7padding: const EdgeInsets.all(16),8child: const Text('Tap for ripple'),9),10)1112// ── Wrap Container in Material for InkWell to show on colors ──13Material(14color: Colors.transparent,15child: InkWell(16onTap: () {},17splashColor: Colors.blue.withOpacity(0.3),18child: Container(19width: 200, height: 60,20decoration: BoxDecoration(21color: Colors.blue,22borderRadius: BorderRadius.circular(8),23),24child: const Center(child: Text('Button', style: TextStyle(color: Colors.white))),25),26),27)
Use InkWell for Material UI elements such as cards, buttons, and list items where the expected ripple effect enhances the user experience. Use GestureDetector for custom widgets where a ripple does not fit, or when you need complex gestures like swipe, pinch, or rotate.
Interaction should feel obvious and reliable:
If users need to guess how to interact, gesture design needs simplification.
Detect taps, swipes, long presses and add ripple effects. Animation gives feedback and personality to UI when it supports user intent clearly.
Build confidence with basics first; speed comes later.
Animate only what helps understanding, and keep transition timing consistent.
Good motion guides attention; bad motion distracts and can hurt performance.
InkWell provides the Material Design ink ripple animation on tap. GestureDetector detects gestures but has no built-in visual feedback.
onLongPress fires when the user holds down on the widget for approximately 500 milliseconds.
InkWell's ripple draws on the nearest Material ancestor. Without wrapping in Material, the container color may hide the ripple effect.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue