didChangeAppLifecycleState method
Called when the app lifecycle state changes.
Stops location tracking when the app enters inactive, paused, detached, or hidden states. Resumes normal operation when the app is resumed.
Implementation
@override
Future<void> didChangeAppLifecycleState(AppLifecycleState state) async {
switch (state) {
case AppLifecycleState.inactive:
case AppLifecycleState.paused:
case AppLifecycleState.detached:
case AppLifecycleState.hidden:
await BackgroundLocator.unRegisterLocationUpdate();
break;
case AppLifecycleState.resumed:
break;
}
}