How to execute something when the app closed

Hi, I want to execute some code, when the user close the app. I try with dispose, but I can´t execute the code when close the app.

" @override
Future dispose() async {
print (“ADIOS”);
desloguear(usuarioConectado);
super.dispose();
}"
How can I execute some lines when the user closes the app?

Hello and welcome.
The following post about app life cycle should be helpful:

1 Like