Addresses the issue that was caused by the maps-lifecycle plugin being pulled to the build.
Normally it was excluded from the flutter plugin explicitly here, and instead lifecycle methods onStart/onStop/onDestroy were called directly on the MapView.
However, other 3-party plugins could still bring the dependency.
The plugin then crashes internally within ViewLifecycleOwner.
In this PR custom Lifecycle is implemented to manage MapView lifecycle calls, maps-lifecycle dependency is no longer excluded.
Custom Lifecycle mirrors lifecycle of the hosting Flutter activity + additionally triggers MapView stop/destroy when widget is disposed but Flutter activity keeps living (that happens easily when MapView is added / removed from the screen).
What is the motivation and context behind this change?
Should fix multiple reported issues about java.lang.IllegalStateException: Please ensure that the hosting activity/fragment is a valid LifecycleOwner : #259, #152, #60, #291, #477, #308, #50.
Pull request checklist:
[x] Add a changelog entry.
[ ] Write tests for all new functionality. If tests were not written, please explain why.
[ ] Add documentation comments for any added or updated public APIs.
What does this pull request do?
Addresses the issue that was caused by the
maps-lifecycle
plugin being pulled to the build. Normally it was excluded from the flutter plugin explicitly here, and instead lifecycle methods onStart/onStop/onDestroy were called directly on the MapView.However, other 3-party plugins could still bring the dependency. The plugin then crashes internally within ViewLifecycleOwner.
In this PR custom Lifecycle is implemented to manage MapView lifecycle calls,
maps-lifecycle
dependency is no longer excluded. Custom Lifecycle mirrors lifecycle of the hosting Flutter activity + additionally triggers MapView stop/destroy when widget is disposed but Flutter activity keeps living (that happens easily when MapView is added / removed from the screen).What is the motivation and context behind this change?
Should fix multiple reported issues about
java.lang.IllegalStateException: Please ensure that the hosting activity/fragment is a valid LifecycleOwner
: #259, #152, #60, #291, #477, #308, #50.Pull request checklist: