📱 Flutter Intermediate

What is GestureDetector in Flutter?

Why Interviewers Ask This

Mid-level Flutter roles require deep understanding of this topic. Interviewers ask this to separate candidates who truly understand the mechanics from those who only know surface-level concepts.

Answer

GestureDetector is a widget that detects touch gestures and triggers callbacks — without adding any visual indicator. It wraps any widget and provides callbacks like onTap, onDoubleTap, onLongPress, onPanUpdate (drag), onScaleUpdate (pinch), and more. It is the primary way to add interactivity to custom widgets that are not inherently tappable. For standard interactive elements like buttons, use built-in widgets like ElevatedButton or InkWell instead, as they include accessibility support.

Common Mistake

Rushing to answer is a common mistake. Take two seconds to structure your response: definition → example → trade-off. This structure makes complex Flutter answers easy to follow.