I need to run a dart code for each 30s even if the application is closed. Is it possible?
Some workarounds suguested is use AlarmManager for Android, but, I not found solution for iOS.
Yes, and I override the didChangeAppLifecycleState method. And in that you cleared the state or navigated to another screen? Well, now I know that you are not the only one facing this issue. And the android docs say that for this functionality resort to native code as much as possible.
There's no good article on how to implement an isolate to work when the app is closed without running some native code. In total, I have spent 2 full days trying to find a package for this, but nothing exists that works. Flutter_Isolate doesn't run when app is killed and Flutter Workmanager can only do print statements but can't take in any functions or any method call. Ultimately pathetic and very annoying. The only solution seems is to write native code to handle background tasks when app is closed. Shame on flutter.
Yes, it is possible. You can run Flutter in background.
In Flutter, you can execute Dart code in the background.
The mechanism for this feature involves setting up an isolate. Isolates are Dart’s model for multithreading, though an isolate differs from a conventional thread in that it doesn’t share memory with the main program. You’ll set up your isolate for background execution using callbacks and a callback dispatcher.
Source: Background processes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With