For more detailed docs on how to lay out widgets in Flutter,
see the layout tutorial.

Gesture detection and touch event handling

This section discusses how to detect gestures
and handle different events in Flutter,
and how they compare with UIKit.

Adding a click listener

In UIKit, you attach a GestureRecognizer to a view to
handle click events.
In Flutter, there are two ways of adding touch listeners:

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

    
@override
Widget build(BuildContext context) {
  return ElevatedButton(
    onPressed: () {
      developer.log('click');
    },
    child: const Text('Button'),
  );
}