Search code examples
buttonflutteruser-interactiongesturedetector

Detect when user interact with the app (Flutter)


I need a little help there.

I want to disconnect the user from the app when he has been inactive for 5 minutes. So I used this solution : Detect when user is not interacting the app in Flutter

It is perfectly working when the user tap on a widget that is not clickable. For example, when I tap on Text widget, the timer is restarting without an issue, but when I tap on a RaisedButton or ListTile, the timer is not restarting.

So, I'm wondering how it is possible for example with this code :

GestureDetector(
  onTap: () => print("gestureDetector"),
  child: RaisedButton(
    onPressed: () => print("raisedButton"),
  ),
),

to print "gestureDetector" AND "raisedButton".

Thank you in advance for your help, cheers ;)


Solution

  • Use a Listener instead of GestureDetector.

    Listener(
      onPointerDown: (e) => print('listener'),
      child: RaisedButton(
        onPressed: () => print('raisedButton'),
      ),
    ),