flutter call api every second even after navigation code example
Example: flutter run in background every second
Timer timer;
void initState() {
super.initState();
timer = Timer.periodic(Duration(seconds: 15), (Timer t) => checkForNewSharedLists());
}
void dispose() {
timer?.cancel();
super.dispose();
}