feat: add use_dialog hook for declarative dialog management#6335
Open
FeodorFitsner wants to merge 8 commits intomainfrom
Open
feat: add use_dialog hook for declarative dialog management#6335FeodorFitsner wants to merge 8 commits intomainfrom
FeodorFitsner wants to merge 8 commits intomainfrom
Conversation
Replace setattr field-copy loop with patch_control(frozen=True) so only actual property deltas are sent to Flutter. This preserves widget identity via _migrate_state (e.g. TextField cursor position) and avoids full re-creation of structural children on every re-render. Also update use_dialog_multiple example with a list of files to demonstrate rename/delete on multiple items.
Deploying flet-examples with
|
| Latest commit: |
cde433c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7f96e30d.flet-examples.pages.dev |
| Branch Preview URL: | https://declr-dialogs-api.flet-examples.pages.dev |
Deploying flet-docs with
|
| Latest commit: |
cde433c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6e8b1d6b.flet-docs.pages.dev |
| Branch Preview URL: | https://declr-dialogs-api.flet-docs.pages.dev |
showDialog's future completes when the route is popped (before the exit animation finishes), causing the dismiss event to fire too early. Capture the ModalRoute in the dialog builder and wait for its .completed Future to finish before updating _open/open properties and triggering the 'dismiss' event. Adds a comment explaining the behavior and moves route capture into the builder.
Keep dismissed dialogs alive in _dialogs.controls and ref until the next render so they remain in session.__index (WeakValueDictionary) long enough for Flutter's dismiss event to reach Python handlers. Remove __prev_lists sync from deferred cleanup to avoid poisoning the diff state when other hooks append to _dialogs.controls in the same render cycle. Add chained dialogs example demonstrating on_dismiss-based sequencing.
…e controls Wait for TransitionRoute.completed before firing dismiss event in BottomSheet, CupertinoAlertDialog, CupertinoBottomSheet, DatePicker, DateRangePicker, and TimePicker — matching the fix already applied to AlertDialog.
Make code samples runnable by adding `ft.run(lambda page: page.render(App))` to the declarative dialogs cookbook. Updated two example blocks in sdk/python/packages/flet/docs/cookbook/declarative-dialogs.md so the App examples are executed when copied/run.
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.
Summary
use_dialog()hook that portals aDialogControltopage._dialogsoverlay from within@componentfunctionspatch_control(frozen=True)) to send only actual property deltas on re-render, preserving Flutter widget identity (e.g. TextField cursor position)open=True/open=Falselifecycle and cleanup on unmountTest plan
use_dialog_basic.py— verify dialog show/dismiss, async delete with "Deleting..." state, canceluse_dialog_multiple.py— verify typing in rename TextField preserves cursor, rename/delete work across multiple filespage.show_dialog()still works alongsideuse_dialogcd sdk/python && python -m pytest🤖 Generated with Claude Code
Summary by Sourcery
Introduce a declarative dialog management hook for Flet components and demonstrate its usage with example apps.
New Features:
Enhancements:
Documentation: