If you app is spawning isolates which are connected to Flutter engines, or you're using some plugin that spawns an isolate which connects to a Flutter Engine such as the FCM plugin, chances are you're going to be having a leaked location stream when you terminate the main isolate on the Android platform.
In the Android federated plugin, The maintainer keeps track of connected engines and he presumes that the plugin is going to be used on any of them, but it might not be the case in many apps.
I'm commenting out the return connectedEngines == 0 check when trying to closing the location service, since I'm only going to be using this service on one isolate.
There should be no harm in doing that as mentioned in issue Baseflow#986 (comment). See 3d9b9e00 for the edit.
The Flutter geolocator plugin is built following the federated plugin architecture. A detailed explanation of the federated plugin concept can be found in the Flutter documentation. This means the geolocator plugin is separated into the following packages:
geolocator: the app facing package. This is the package users depend on to use the plugin in their project. For details on how to use thegeolocatorplugin you can refer to its README.md file.geolocator_android: this package contains the endorsed Android implementation of the geolocator_platform_interface and adds Android support to thegeolocatorapp facing package. More information can be found in its README.md file;geolocator_apple: this package contains the endorsed iOS and macOS implementations of the geolocator_platform_interface and adds iOS and macOS support to thegeolocatorapp facing package. More information can be found in its README.md file;geolocator_web: this package contains the endorsed web implementation of the geolocator_platform_interface and adds web support to thegeolocatorapp facing package. More information can be found in its README.md file;geolocator_windows: this package contains the endorsed Windows implementation of the geolocator_platform_interface and adds Windows support to thegeolocatorapp facing package. More information can be found in its README.md file;geolocator_platform_interface: this package declares the interface which all platform packages must implement to support the app-facing package. Instructions on how to implement a platform package can be found in the README.md of thegeolocator_platform_interfacepackage.