Wisit Phusi
Wisit Phusi

Reputation: 451

Is it possible to run code when app terminated?

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

Answers (2)

Günter Zöchbauer
Günter Zöchbauer

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

Yakup Okumuş
Yakup Okumuş

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

Related Questions