Reputation: 510
I have a personal expenses app in which I have a Week model which holds user expanses over week and at the end of the week uploads it in cloud. My problem is that how can I implement a situation in which Week model is created at first day of week(eg.saturday) periodically even if the app is not running??? Is that even possible?? I searched a little and saw
timer.periodic(duration,callback);
but I don't think that would work in background
Upvotes: 0
Views: 1742
Reputation: 218
You can use background_fetch plugin. But this plugin's lack of it is that works stable on just Android. You need to read the official document.
Upvotes: 1
Reputation: 130
Maybe this will help you:
You have to use Timer
from dart:async
to run periodically method, and put the duration for 7 days.
Timer.periodic(
Duration(days: 7),
(timer){
// Create new week model in database.
}
);
Use workmanager
to run the previous code in the background, it will executed weekly.
Upvotes: 1