'Disable location services when leaving map screen (Flutter )

I’m using this flutter package to manage location services in my flutter app : https://pub.dev/packages/geolocator

I want to disable the active state of the location service (after some seconds) when the user is not on the map screen .

Please help .



Solution 1:[1]

You can dispose of it after the user leaves the particular screen:

void dispose() {
    // Dispose any controller...
    super.dispose();
}  

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stephen Ostermiller