Button - trigger onPressed when button first touched, instead of touched and released

Hi all,

Just started using Flutter a couple days ago and I’m enjoying it a lot.

I noticed that when I use a FlatButton, onPressed gets called when the button is touched then released.

Is there a similar widget to FlatButton that has a callback when its touched, and perhaps a call back when it is released?

Thanks!

Hey @SharkWithLasers , I think what you are looking for is onLongPress property of Gesture detector.

Gesture Detector can be used as a wrapper for any widget let that be a container, row, column, image, etc. Here’s an example:
Let me know if this helps :slight_smile:

GestureDetector(
      onLongPressStart: (LongPressStartDetails details) {print("LONG PRESS START");},
      onLongPressEnd: (LongPressEndDetails details) {print("LONG PRESS End");}, 
      child : Container())
1 Like