dispose method
Releases native resources associated with this controller.
Typically invoked by GemMap lifecycle management.
After calling this method, the controller instance should be considered invalid. Do not call any other methods on this instance after calling dispose. Also avoid using instances linked to this controller, such as MapViewPreferences, FollowPositionPreferences and collections.
Teardown order:
- nativeClear — cancel the debounce timer and unregister this controller from the event-handler dispatcher so straggler events arriving in the window between this and step 2 are dropped at the Dart-side dispatch boundary.
- clearListeners — null all callback fields so closures captured by the user (typically referencing widgets/controllers) become GC-eligible.
releaseView— release the native view object.
Steps 1 and 2 are deliberately not delegated to the inherited
EventHandler.dispose template, so that the awaited releaseView call
runs in a single coherent body.
Implementation
@override
Future<void> dispose() async {
nativeClear();
clearListeners();
await releaseView();
}