Repository navigation
Conversation
When the close request could not be made, WindowCaption fell back to Application.quit() regardless of the window it was given. In a multi-window app the close button of a secondary window's caption could therefore end the whole application. Only a caption that follows the current window (no `window` given) keeps the quit fallback. Window.close() returns true once the request is made and a veto arrives asynchronously, so a vetoed close is unaffected.
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
When the close request cannot be made,
WindowCaption's close button falls back toApplication.instance.quit(0), whether or not the caption was given awindow. In a multi-window app, the close button of a secondary window's caption can therefore end the whole application.Change
Only a caption that follows the current window (no
windowgiven) keeps the quit fallback. A caption given its window only asks that window to close.Window.close()returns true once the request is made and a veto arrives asynchronously, so a vetoed close (prevent-close) is not affected either way.Tests
New
test/window_caption_close_test.dart: with a window whoseclose()reports failure, tapping the close button sends the request to that window only and raises nothing. WhetherApplication.quitwould have run is not observable from a widget test without adding a test hook to the widget, so this test documents the path rather than failing on the old code; I can add a seam if you prefer.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 (this); legacy bridge #602, #603, #604, #605, #606.Touches
window_caption.dartlike #600 (scoped listeners); the two merge cleanly in either order.