Visitar URL original
fix(legacy): keep the event bridge compiling when nativeapi adds events by palmoni5 · Pull Request #604 · leanflutter/window_manager · GitHub
Skip to content

fix(legacy): keep the event bridge compiling when nativeapi adds events - #604

Open
palmoni5 wants to merge 1 commit into
leanflutter:mainfrom
palmoni5:upstream/legacy-event-forward-compat
Open

palmoni5 wants to merge 1 commit into
leanflutter:mainfrom
palmoni5:upstream/legacy-event-forward-compat

Conversation

@palmoni5

@palmoni5 palmoni5 commented Nov 10, 2026 •

Copy link
Copy Markdown

Problem

nativeapi.WindowEvent is sealed and window_manager depends on nativeapi: ^0.5.5. The bridge in package:window_manager/legacy.dart switches over it exhaustively, so a nativeapi 0.5.x release that adds a WindowEvent subclass would turn that switch into a compile error for every app using the bridge, without any change on the app's side.

Change

Events without a 0.5.x counterpart (created, closed, property and occlusion changes) go through a default branch instead of an explicit list. The branch stays reachable, so the analyzer does not flag it, and a future event type is ignored instead of breaking the build.

Also adds @visibleForTesting debugBindWindow(nativeapi.Window?) so tests can drive the bridge with a simulated nativeapi.Window.

Tests

New test/legacy_event_compat_test.dart with a fake nativeapi.Window: events without a 0.5.x counterpart are dropped, and handled events around them still arrive. (A test cannot add a subclass to a sealed class, so the compile-time part is covered by the analyzer run.)

dart format --set-exit-if-changed ., flutter analyze (package and example) and flutter 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 main and mergeable on its own: widgets #598, #599, #600, #601; legacy bridge #602, #603, #604 (this), #605, #606.

#602 and #605 add the identical debugBindWindow test seam; all legacy PRs merge cleanly with this one. If #606 lands too, debugBindWindow can delegate to bindWindow.

nativeapi's WindowEvent is sealed and the dependency is ^0.5.5, so a
0.5.x release that adds a WindowEvent subclass would make the exhaustive
switch in the legacy bridge a compile error for every app using it.

Events without a 0.5.x counterpart (created, closed, property and
occlusion changes) now go through a default branch instead of an
explicit list. The branch stays reachable, so the analyzer does not flag
it, and a future event is ignored instead of breaking the build.

Adds a @VisibleForTesting debugBindWindow so the bridge can be driven
by a simulated nativeapi.Window in tests.
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