Flutter listen to lifecycle events on Stateless Widget?


Is there any solution for listening to lifecycle events for a StatelessWidget when the app is in background / foreground ? There is no StatefulWidget on that particular screen. I am using Getx() controller to observe data changes.


For GetX architechture you dont have to use StatefulWidget but to listen lifecycle changes,
it seems like you have to use StatefulWidget.

Just override this method in a StatefulWidget.

Future<void> didChangeAppLifecycleState(AppLifecycleState state) async 
if (state == AppLifecycleState.paused) {}
else if (state == AppLifecycleState.resumed) {}

Answered By – rishabh mistry

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *