Skip to content

Conversation

@FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Aug 13, 2025

Fix #5487
Fix #5439

Summary by Sourcery

Enable live updates of AlertDialog, CupertinoAlertDialog, and Banner controls by rebuilding them via ControlInheritedNotifier instead of caching, add error handling for missing content, and enhance the Python SDK dialog lifecycle methods by removing deprecated Page.open/close and improving show_dialog/pop_dialog docstrings and async on_dismiss handling.

Bug Fixes:

  • Prevent stale dialog instances by removing cached _dialog fields and rebuilding dialogs on each open
  • Show explicit ErrorControl messages when required dialog or banner content/actions are missing

Enhancements:

  • Wrap dialog widgets in ControlInheritedNotifier to react to property or action changes
  • Replace deprecated Page.open/close methods in the Python SDK and refactor show_dialog/pop_dialog for proper async dismissal and state management

Documentation:

  • Add detailed docstrings to show_dialog and pop_dialog describing their behavior, arguments, and exceptions

Removed deprecated 'open' and 'close' methods in favor of 'show_dialog' and 'pop_dialog'. Enhanced 'show_dialog' to better manage dialog lifecycle and dismissal, including improved event handling and error checking. Updated docstrings for clarity and maintainability.

Fix #5439
Replaces direct widget construction with ControlInheritedNotifier in both AlertDialogControl and CupertinoAlertDialogControl for improved state management. Error handling is now managed via a string error message instead of an ErrorControl widget instance.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 13, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 11041c2
Status: ✅  Deploy successful!
Preview URL: https://470ea8bf.flet-docs.pages.dev
Branch Preview URL: https://v1-alert-dialog-fix.flet-docs.pages.dev

View logs

Copy link
Contributor

Copilot AI left a 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 fixes issues with updating properties or actions of opened AlertDialog, CupertinoAlertDialog, and Banner controls by replacing cached dialog instances with live rebuilding through ControlInheritedNotifier. The fix addresses stale dialog instances and improves the Python SDK dialog lifecycle methods.

  • Replaces cached _dialog fields with ControlInheritedNotifier wrapper for live updates
  • Improves Python SDK dialog methods by removing deprecated functions and enhancing async handling
  • Adds integration tests to verify dynamic dialog property updates

Reviewed Changes

Copilot reviewed 6 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sdk/python/packages/flet/src/flet/controls/base_page.py Removes deprecated methods, enhances show_dialog/pop_dialog with better async handling and documentation
packages/flet/lib/src/controls/alert_dialog.dart Wraps dialog in ControlInheritedNotifier for live updates, removes cached _dialog field
packages/flet/lib/src/controls/cupertino_alert_dialog.dart Similar changes to AlertDialog - adds ControlInheritedNotifier wrapper and removes caching
packages/flet/lib/src/controls/banner.dart Simplifies banner creation by removing caching and using direct error string handling
sdk/python/packages/flet/integration_tests/controls/test_alert_dialog.py Adds test for dynamic dialog property updates with screenshots
sdk/python/packages/flet/integration_tests/controls/test_cupertino_alert_dialog.py Adds test for dynamic Cupertino dialog action updates with screenshots

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@FeodorFitsner FeodorFitsner merged commit c739fb2 into main Aug 15, 2025
5 checks passed
@FeodorFitsner FeodorFitsner deleted the v1-alert-dialog-fix branch August 15, 2025 18:51
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.

TextButton.visible = True not working in AlertDialog v1: AlertDialog on_dismiss is never called

3 participants