I developed my app for Android using Java and now want to migrate to Flutter.
For detecting user inactivity I override this method in my Activity: onUserInteraction
and reset a Timer
, if there is no user interaction, I show a Screen Saver like Animation.
Is there Any clean way in Flutter to do this? I don't want to use platform channels. I want it pure Dart and flutter. I know I can set timer and reset it on user touch, but like in Android I want system to inform me about the user interaction.
You can handle this by creating a sessionActivityListener class
Your timer will be used to countdown once the onSessionTimeout function is triggered
After these, just wrap your material app with the sessionactivity listener and pass the required arguments.
Please note
the loggedInStatus is an enum that notifies the event of a successful login, and this is because your session inactivity callback function should ideally only run when the user has an active session i.e is logged in
i created the enum this way
and the _timeout function handles the callback. I hope this helps.