Search code examples
androidiosfluttermobiledart

Is there any app interaction detector in flutter?


I am developing a flutter app where I want to display an Alert when there is no interaction with the app for some time (say 5 mins). How do I achieve this?


Solution

  • Here you go

    1. setup a variable and initialize it with current time
    2. setup a timer that tick for every second.
    3. when ever user interact with your app, (Gesture, button click etc.) simply update the current time to the variable that we setup on the step 1.
    4. on each timer tick, check the difference between the current time and the time we noted on step 1 is equal to or grater than 5 mins, then present the dialog box to the user as per your requirement.

    That's all.