Component - GestureDetector
The GestureDetector widget in Flutter detects user gestures like taps, double taps, and swipes on its child widget. It lets you respond to touch events, making your app interactive.
The GestureDetector widget in Flutter detects user gestures like taps, double taps, and swipes on its child widget. It lets you respond to touch events, making your app interactive.
Scaffold
├─ AppBar
│ └─ Text
└─ Center
└─ GestureDetector
└─ Container
└─ TextGestureDetector widget in Flutter?onTap. Other callbacks like onClick, onPressed, and onTouch do not exist on GestureDetector.onTap and a child widget, making it valid Flutter code.GestureDetector(
onTap: () => print('Tapped!'),
child: Text('Click me'),
)GestureDetector(
onTap: print('Tapped'),
child: Text('Tap me'),
)print('Tapped') runs immediately and assigns its result (void) to onTap, which is incorrect.() => print('Tapped') or (){ print('Tapped'); } to run on tap.onTap for taps and onLongPress for long presses. GestureDetector(onTap: () => print('Tap'), onLongPress: () => print('Long press'), child: Container()) uses both correctly.Pass the test and this pattern moves unknown