I have used to Timer.periodic in flutter to run a function for every minnute
final periodicTimer = Timer.periodic(
const Duration(minutes: 1),
(timer) {
print('some code here');
});
so the problem here is whenever the function is getting triggered
lets say i added this function in a second screen
once if i go to that page its creating one request
if i go multiple times to that page it is adding multiple timers
after everyminnute
"some code here "
is being printed as many times as I fire that page (which has that periodic timer function)
but is there any way where no matter how many times it is fired up it should just run that function for every minnute
tried various other methods used timer.cancel() [which will completely cancel the timer]
and followed various stackoverflow threads which i couldnt make it work
any insights or any other way to get this approach ?