Solution 1 :
You can use https://docs.flutter.io/flutter/widgets/WidgetsBindingObserver-class.html with https://docs.flutter.io/flutter/dart-ui/AppLifecycleState-class.html
I think suspending
is the closed and to my experience it is also called before the app is killed.
Problem :
Is there any possibility to run code before a Flutter app is shutdown?