Refresh after inactivity

Actions & Logic

When someone logs into my app they are redirected to the logged in page. Let's say the user works in the app for a bit and then closes it and moves on with their day. Hours later they come back to the app. How do I have the app auto refresh the page (and database calls)?

This is similar to have Facebook or Instagram or any other social media apps work. When you come back and open the app everything is refreshed with the new posts/content.

What have you tried so far?

I've considered a periodic timer but I don't want to refresh if the user is actively using the app. How would I monitor activity and only refresh if they became active after a specified period of inactivity?

I considered the idea of tracking the user on clicks/visits to other pages that would then assess activity and only after x min of inactivity (clicks - not scrolling) would it then do a refresh. The problem with this is that I would need to create an app state variable that is changed on every navigate to or navigate back (assuming they are going back to the home screen). But that is another issue. What if they get to a page within the app but not from the home screen and navigate back. The back button would trigger the periodic refresh but shouldn't because they are still active just not active on the home screen.

Did you check FlutterFlow's Documentation for this topic?
Yes
1
2 replies