-
Notifications
You must be signed in to change notification settings - Fork 596
Fix app start with a hidden window #5838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Moved window logic from controls/window.dart to services/window.dart, converting WindowControl to WindowService and updating its integration. Updated page and core extension to use the new service, removed window overlay from view, and adjusted backend and related code to support the refactor. This change improves separation of concerns by treating window management as a service rather than a UI control.
Added comments explaining how to run the example with the --hidden option using `flet run`. Also added a print statement to notify that the window is hidden on start and will show after 3 seconds.
Refactored material time picker integration tests for improved clarity and consistency, updating dialog creation and page update order. Added a new example for window resizing in desktop apps. Updated golden image and other related test files.
Added explicit page update and await pump_and_settle before opening the time picker in test_basic. This ensures the page is fully rendered and stable before interaction, reducing test flakiness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've reviewed this pull request using the Sourcery rules engine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors desktop window handling in Flet by converting the WindowControl widget to a WindowService, addressing issue #2705 where windows hidden at startup would not become visible when toggled.
Key changes:
- Refactored WindowControl from a StatefulWidget to a FletService for better lifecycle management
- Fixed hidden window retrieval by using
visibleOnly: falseparameter in backend communication - Updated Python SDK integration tests to use consistent
page.update()andpump_and_settle()sequences
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/flet/lib/src/services/window.dart | Refactored from StatefulWidget to FletService with improved initialization and platform checks |
| packages/flet/lib/src/controls/page.dart | Added service registry management for window, page, and user services with proper lifecycle handling |
| packages/flet/lib/src/flet_backend.dart | Added visibleOnly: false parameter for hidden window retrieval and rethrow for connection errors |
| packages/flet/lib/src/flet_core_extension.dart | Moved Window from widget factory to service factory |
| packages/flet/lib/src/controls/view.dart | Removed embedded WindowControl widget from view overlays |
| sdk/python/examples/controls/page/window_hidden_on_start.py | New example demonstrating hidden window startup with visibility toggle |
| sdk/python/examples/controls/page/window_resize.py | New example showing programmatic window resizing |
| sdk/python/packages/flet/integration_tests/examples/material/test_time_picker.py | Updated test to call page.update() before showing dialog for stability |
| sdk/python/packages/flet/integration_tests/examples/material/test_context_menu.py | Added pump_and_settle() after page update for consistency |
| sdk/python/packages/flet/integration_tests/examples/cupertino/test_cupertino_action_sheet.py | Reordered operations to update page before adding dialog |
| sdk/python/packages/flet/integration_tests/examples/core/test_shader_mask.py | Refactored to separate image creation, update page, then add shader mask |
| sdk/python/packages/flet/integration_tests/controls/material/test_time_picker.py | Updated tests with consistent update and pump patterns |
| sdk/python/packages/flet/integration_tests/examples/material/golden/macos/context_menu/programmatic_open.png | Updated golden test image |
Comments suppressed due to low confidence (1)
packages/flet/lib/src/services/window.dart:99
- If an error occurs during window state initialization (line 97-99), the
_initWindowStateCompleteris never completed. This could cause_scheduleWindowUpdate()to hang indefinitely waiting for the completer to finish (line 114-115). Consider completing the completer with an error in the catch block:_initWindowStateCompleter.completeError(e);or complete it normally to allow the app to continue.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Eliminated the rethrow statement in the FletBackend connection error handler to prevent exceptions from propagating and to handle errors more gracefully.
Deploying flet-docs with
|
| Latest commit: |
7c4528c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://eb21be13.flet-docs.pages.dev |
| Branch Preview URL: | https://start-hidden-window-fix.flet-docs.pages.dev |
Fix #2705
Summary by Sourcery
Refactor desktop window handling by replacing the WindowControl widget with a dedicated WindowService, fix hidden window startup behavior, and streamline service bindings in PageControl. Update Python SDK integration tests for improved stability and add new examples for hidden and resized windows.
New Features:
Bug Fixes:
FLET_APP_HIDDEN#2705)Enhancements:
Documentation:
Tests: