Gesture detection and touch event handling

How do I add an onClick listener to a widget in Flutter?

In Android, you can attach onClick to views such as button by calling
the method ‘setOnClickListener’.

In Flutter there are two ways of adding touch listeners:

If the Widget supports event detection, pass a function to it and handle it
in the function. For example, the ElevatedButton has an onPressed parameter:

If the Widget doesn’t support event detection, wrap the
widget in a GestureDetector and pass a function to the onTap parameter.

How do I handle other gestures on widgets?

Using the GestureDetector, you can listen to a wide range of Gestures such as:

Tap