Reputation: 2792
i have read the flutter documentation about GestureDetector and i can only see onTapDown & onTapUp
and i believe if there is up and Down there will be Right and Left
how can i achieve onTapRight and onTapLeft
Upvotes: 0
Views: 777
Reputation: 2792
thanks to @L.Gangemi that gave me the idea of what to use....
i solved this by this sample code
onTapUp: (details) {
if (details.localPosition.direction >
1.0) {
print('Left');
}
if (details.localPosition.direction <
1.0) {
print('Right');
}
},
Upvotes: 1
Reputation: 3290
onTapDown & onTapUp do not refer to the area/position where you press, but they do refer to:
onTapDown: The moment your finger actually touch the screen
onTapUp: The moment your finger leave the screen
From the docs:
onTapDown: A pointer that might cause a tap with a primary button has contacted the screen at a particular location.
onTapUp: A pointer that will trigger a tap with a primary button has stopped contacting the screen at a particular location
To achieve right or left tap, you could use a Stack
widget to overlay a row
with 2 Gesture dector widgets.
DOCS:
onTapDown GestureTapDownCallback
Upvotes: 2