Skip to content

fix: dispose keyboard leaping notifiers - #2296

Open
gregpakes wants to merge 1 commit into
fleaflet:masterfrom
gregpakes:fix/dispose-leaping-notifiers
Open

gregpakes wants to merge 1 commit into
fleaflet:masterfrom
gregpakes:fix/dispose-leaping-notifiers

Conversation

@gregpakes

Copy link
Copy Markdown

MapInteractiveViewerState creates _isPanLeaping, _isZoomLeaping and _isRotateLeaping but never disposes them, so leak_tracker reports them for every FlutterMap. _ckrTriggered, the other ValueNotifier<bool> in that class, is already disposed.

This is the bookkeeping only: there is no user-visible behaviour change.

Why dispose is safe here. After dispose(), the notifiers have two possible writers in maybeLeap. listenForLeapCompletion is driven by a keyboard animation controller, so the new calls come after _disposeKeyboardAnimations(). The cancelLeap.then callback only runs when a key event completes the completer, and the widget gets no key events once it is gone.

Tests. Two added to map_interactive_viewer_test.dart:

  • Every ValueNotifier<bool> the map creates is disposed, tracked through FlutterMemoryAllocations. This fails without the change.
  • The map can be torn down during a keyboard leap without throwing. A temporary trace confirmed the leap starts and has not ended when the map is removed.

The full suite and dart analyze pass locally on Flutter 3.47.4.

AI disclosure. I used Claude Code to find this, write the change and write the tests.

🤖 Generated with Claude Code

MapInteractiveViewerState created _isPanLeaping, _isZoomLeaping and
_isRotateLeaping but never disposed them, so leak_tracker reports every map.

They are disposed after the keyboard animations, because those drive the
listeners that write them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gregpakes
gregpakes marked this pull request as ready for review November 1, 2026 16:45

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant