Conversation
Deploying flet-docs with
|
| Latest commit: |
5caecdb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://37737696.flet-docs.pages.dev |
| Branch Preview URL: | https://improve-events.flet-docs.pages.dev |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the event handling system to improve the structure and consistency of position and delta data across Python and Dart implementations. The changes replace individual x/y coordinate fields with unified Offset objects and restructure serialization to use nested coordinate maps.
- Unifies positional data into Offset objects with proper type annotations and comprehensive docstrings
- Changes Dart serialization from flat coordinate fields to nested x/y maps for better structure
- Updates GestureDetector state tracking to use Offset objects instead of separate x/y variables
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| sdk/python/packages/flet/tests/test_events.py | Updates test assertions to use new Offset-based event structure and nested coordinate maps |
| sdk/python/packages/flet/src/flet/controls/events.py | Replaces individual x/y fields with Offset objects and adds comprehensive docstrings for all event classes |
| packages/flet/lib/src/utils/events.dart | Converts flat coordinate serialization to nested x/y maps and updates method signatures |
| packages/flet/lib/src/controls/gesture_detector.dart | Refactors state variables from separate x/y coordinates to Offset objects |
Comments suppressed due to low confidence (2)
sdk/python/packages/flet/src/flet/controls/events.py:193
- The field name 'global_focal_point_x' suggests it contains only x-coordinate data, but it's typed as Offset which contains both x and y coordinates. It should be named 'global_focal_point' to match its type and usage.
global_focal_point_x: Offset = field(metadata={"data_field": "gfp"})
packages/flet/lib/src/utils/events.dart:119
- The _globalPan variable is being assigned details.localPosition instead of details.globalPosition. This will result in incorrect global position tracking.
"l": {"x": localPosition.dx, "y": localPosition.dy},
|
|
||
| local_delta: Optional[Offset] = field(default=None, metadata={"data_field": "ld"}) | ||
| """ | ||
|
|
There was a problem hiding this comment.
The docstring for local_delta is empty. It should describe what this field represents, similar to other documented fields in the class.
| The amount the pointer has moved in the local coordinate space of the event receiver | |
| since the previous update. May be `None` if not provided by the event source. |
|
|
||
| local_delta: Optional[Offset] = field(default=None, metadata={"data_field": "ld"}) | ||
| """ | ||
|
|
There was a problem hiding this comment.
The docstring for local_delta in PointerEvent is empty. It should describe what this field represents, similar to other documented fields in the class.
| The change in the pointer's position in the local coordinate space since the last event, | |
| in logical pixels. May be None if not applicable. |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Feodor Fitsner <[email protected]>
Closes #825
Test code
Summary by Sourcery
Refactor event handling to unify positional, delta, and velocity data into composite Offset structures across Python and Dart, simplify serialization to nested x/y maps, and update gesture detector to track state using Offset.
Enhancements: