Repository navigation
Conversation
Move and resize events arrive many times per second while the user drags a window. For each event the bridge copied the listener list, and for each listener it built a map of fifteen callback tear-offs just to call one of them. Delivery now iterates a listener snapshot that is rebuilt only when listeners are added or removed, and calls the named callback through a switch. It returns early without listeners. Delivery semantics are unchanged: listeners added by a callback join from the next event, and removed ones are skipped immediately.
This was referenced Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Move and resize events arrive many times per second while the user drags a window. For each event the 0.5.x bridge (
package:window_manager/legacy.dart) copies the listener list, and for each listener it builds a map of fifteen callback tear-offs just to call one of them.Change
switchinstead of a per-listener map._emitreturns early without listeners.Delivery semantics are unchanged: listeners added by a callback join from the next event, removed ones are skipped immediately, and
listenersstill returns a copy.Tests
New
test/legacy_dispatch_test.dart(driven throughclose()with prevent-close, which needs no window): the named callback followsonWindowEventonce per event, removing a listener during delivery does not starve later listeners, a listener added during delivery joins the next event only, andlistenersreturns a copy. These pin the existing semantics, so they pass before and after the change.dart format --set-exit-if-changed .,flutter analyze(package and example) andflutter test(package and example) pass locally (Flutter 3.47.7, Windows), and the full CI workflow passes on the identical commit in my fork.Related
Part of a set of independent PRs, each based on
mainand mergeable on its own: widgets #598, #599, #600, #601; legacy bridge #602, #603 (this), #604, #605, #606.Merges cleanly with the other legacy PRs (#602, #604, #605, #606).