Reputation: 451
I want to know that is it possible to run code when app terminated?
And how Can I do that if it is possible to do?
Upvotes: 8
Views: 8403
Reputation: 657248
WidgetsBindingObserver
allows you to react to lifecycle events like suspending
.
There is not really a terminated state, especially on iOS.
If you want to run code while the app isn't running in foreground, you can follow https://github.com/flutter/flutter/issues/3671
Upvotes: 8
Reputation: 188
You can use background_fetch
, check this article
https://khore-sid2.medium.com/run-flutter-app-in-background-terminated-state-82f70a0eb999
and work manager
(ios part could be complicated) plugin
Upvotes: 0