Detect when user interact with the app (Flutter)

1,733

Use a Listener instead of GestureDetector.

Listener(
  onPointerDown: (e) => print('listener'),
  child: RaisedButton(
    onPressed: () => print('raisedButton'),
  ),
),
Share:
1,733
NqbraL
Author by

NqbraL

Updated on December 15, 2022

Comments

  • NqbraL
    NqbraL over 1 year

    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 ;)

    • NqbraL
      NqbraL over 4 years
      Btw, I've tried to use IgnorePointer widget or the behavior property of GestureDetector : not working :'(
  • NqbraL
    NqbraL over 4 years
    Wow, thank you for this quick answer and the solution is working fine ! Love u mate :D
  • user481610
    user481610 about 4 years
    You sir need a medal. This works very nicely to handle session management.