didChangeAppLifecycleState method
- AppLifecycleState state
override
Método que detecta cuando la app se abre o se minimiza
Implementation
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
start(); // SI LA APP SE ABRE, SE REANUDA EL CONTADOR
} else if (state == AppLifecycleState.paused ||
state == AppLifecycleState.inactive ||
state == AppLifecycleState.detached) {
stop(); // SI LA APP SE MINIMIZA, SE DETIENE EL CONTADOR
}
}