Flutter for web - GestureDetector around RaisedButton

Viewed 1643

For context: https://dartpad.dev/c9689b40a5402e12538c726b5c0380ff

I have a GestureDetector (that has some specific business logic) that listens to single taps and has a child as parameter.

In a specific location, I want this child widget to look like a button. However, using a real button widget apparently skips the onTap of GestureDetector.

At first I thought that onTapCancel would then kick in, but for onTapCancel to trigger the widget needs to be 'long pressed'.

Any suggestions on how to solve this? (Using IgnorePointer around the child doesn't work.)

1 Answers

AbsorbPointer

  Widget build(BuildContext context) {
    return GestureDetector(
        child: AbsorbPointer(child : child),
        onTap: () {
          print('tap');
          onTap();
        },
        onTapCancel: () {
          print('tapCancel');
        });
  }
Related