Reputation: 20484
When using GestureDetector to update the Size of a Widget, how would you exit the gesture completely once the user has reached a certain point? Is there a way to tell Flutter to stop listening to this drag gesture even whilst it is still being dragged as if the user had removed their finger from the screen.
GestureDetector(
onVerticalDragUpdate: (details) {
if(details.globalPosition.dy > 100){
// kill this gesture completely as if the user has removed their finger from the screen
}
})
Upvotes: 0
Views: 282
Reputation: 63829
You can try this way, it has some pixel issue based on drag velocity(I think)
bool enabled = true;
@override
Widget build(BuildContext context) {
return GestureDetector(
onVerticalDragUpdate: enabled
? (details) {
print(details.globalPosition.dy);
if (details.globalPosition.dy > 100) {
enabled = false;
setState(() {});
return;
}
}
: null,
);
}
Upvotes: 1