Skip to content

Conversation

@FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Nov 10, 2025

Fix #5787
Fix #5799

This pull request introduces two main groups of changes: improvements to error message customization in the Flet app loading screen, and a substantial expansion of gesture event handling capabilities in the GestureDetectorControl. These updates enhance both the user experience during app startup and the range of gestures that can be detected and handled within the app.

Error message customization:

  • Added the FletApp.appErrorMessage template, allowing developers to customize the error message shown on the loading screen when an error occurs. This is reflected in the changelogs and integrated into the app initialization and control state. [1] [2] [3] [4] [5]

Gesture detection enhancements:

  • Greatly expanded the set of gesture events that GestureDetectorControl can handle, including new events for tap, double tap, long press, drag, pan, and force press (such as onTapMove, onTapCancel, onDoubleTapCancel, onLongPressMoveUpdate, onHorizontalDragCancel, onForcePressStart, etc.). These events are now properly checked, and their handlers are wired to trigger corresponding control events, enabling much finer-grained gesture interaction. [1] [2] [3] [4] [5] [6]

  • Refactored event handler logic to remove unnecessary storage of TapDownDetails and to simplify the triggering of gesture events, ensuring that only the relevant data is passed to event handlers. [1] [2]

These changes improve both the flexibility of the app's startup error reporting and the responsiveness and versatility of gesture-based controls.

Summary by Sourcery

Enable customizable startup error messages, expand gesture detection capabilities with fine-grained events, enhance Python error reporting, and introduce a use_ref hook for reusable state in components.

New Features:

  • Add FletApp.appErrorMessage template to customize loading screen error messages
  • Introduce a wide range of new gesture events in GestureDetectorControl (tap move/cancel, double tap variants, long press variants, drag/pan cancel, force press events)
  • Add use_ref hook for Python components

Bug Fixes:

  • Improve error handling in Python connections and session dispatch to capture and report stack traces
  • Correct parseTabBarTheme configuration key

Enhancements:

  • Refactor GestureDetectorControl event logic to simplify handler wiring and remove stored TapDownDetails
  • Replace direct window size manipulation in tests with resize_page API
  • Add fullscreen_dialog property to View control

Introduces a fullscreen_dialog boolean property to the View class, allowing views to be marked as fullscreen modal dialogs.
Removed unused TapDownDetails state in Dart GestureDetector and simplified tap event triggers to not require tap down details. Updated Python GestureDetector to use ControlEventHandler for tap events instead of EventHandler for consistency and improved type safety.

Fix #5786
Expanded GestureDetector to support new gesture events including tap move/cancel, secondary/tertiary tap cancel, long press down/cancel/move update/up, secondary/tertiary long press variants, double tap cancel, drag down/cancel, pan down/cancel, and force press events. Updated Dart and Python event mapping, event classes, and control properties to enable richer gesture handling and event data propagation.
Updated file picker examples to use local instances instead of appending to page services. Introduced a State dataclass in pick_and_upload.py for better state management and improved code clarity.
Refactored error handling across Flet backend and Python SDK to use structured logging instead of print/traceback, and to propagate error messages more consistently to the client. Now, errors in before_main and event handlers are logged with stack traces and sent to the session, and session creation is aborted if before_main fails. Also fixed a bug in Dart backend where isLoading was incorrectly set on error.
Introduced the `FletApp.appErrorMessage` template to allow customization of loading screen error messages. Updated error handling to include stack traces for better debugging in Python and Dart backends. Adjusted UI components to use the formatted error message template.
Corrects the key from 'tabs_theme' to 'tab_bar_theme' when parsing the tab bar theme in the parseTheme function, ensuring the correct theme property is used.
Replaced direct assignments to page.window.width and page.window.height with calls to resize_page in integration tests. This improves consistency and maintainability of test setup. Also removed an unused import and updated golden image assets for markdown and snack bar tests.
Replaces 'await flet_app.resize_page(...)' with synchronous 'flet_app.resize_page(...)' in all integration test files. This change reflects an update to the resize_page method, which is now synchronous and no longer requires awaiting.
Introduces the use_ref hook and MutableRef class to allow components to preserve mutable values across renders without causing re-renders. Updates __init__.py to export use_ref.
Added a new declarative audio player example using flet_audio. Updated the shake detector example to store the ShakeDetector instance in the session store instead of appending to services, ensuring a reference is held for session management.
@FeodorFitsner FeodorFitsner linked an issue Nov 10, 2025 that may be closed by this pull request
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 Nov 10, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 80aef5c
Status: ✅  Deploy successful!
Preview URL: https://eeed3456.flet-docs.pages.dev
Branch Preview URL: https://v1-fullscreen-dialog-fix.flet-docs.pages.dev

View logs

Created a new documentation page for the use_ref type and added it to the mkdocs navigation under types.
Replaced placeholder 'TBD' docstrings with descriptive explanations for FletApp class attributes, improving code documentation and clarity.
Corrects the use of the 'frozen' parameter in DiffBuilder methods to ensure it is passed through instead of being hardcoded. Adds a test to verify that lists with keys can be updated correctly.
@FeodorFitsner FeodorFitsner merged commit 8240267 into main Nov 10, 2025
32 of 47 checks passed
@FeodorFitsner FeodorFitsner deleted the v1-fullscreen-dialog-fix branch November 10, 2025 19:33
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.

bug: [V1] Control with key: RuntimeError: Frozen controls cannot be updated. [v1] Exceptions inside before_main are silent

2 participants