Flutter onPressed() vs onTap()

The Source of differents between onTap and onPressed is GestureDetector used in buttons.
onTap should give you response in the first moment touching the screen.
onPressed should be equvalent to .onTapDown property - the last moment touching the screen.


In my experience, onTap() is used for any gesture capture and onPressed() especially for buttons. Just like in real life, when you have to use a button, you'll press it.

Hope this will solve your troubles even though I'm not totally sure about that.


Currently they both are same. Just use onPressed with Buttons and onTap with other widgets.

Flutter is still new so there are lots of overlaps. May be in future updates they will make it more streamline . Like they will merge many widgets which are almost same.

Tags:

Flutter