flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.04k stars 427 forks source link

GestureDetector on_exit method throw an error / don't work anymore on v0.23.2 #3558

Closed azhago closed 2 months ago

azhago commented 3 months ago

Duplicate Check

Describe the bug

Hi, In v0.23.2, the GestureDetector doesn't work

It was OK till v0.23.1

Code

import flet as ft

gesture_container:ft.GestureDetector = ft.GestureDetector(
    content=ft.Container(
        width=100,
        height=100,
        bgcolor="blue",
    ),
    on_hover=lambda e: print("hover"),
    on_exit=lambda e: print("exit"),
)

container:ft.Container = ft.Container(
    width=600,
    height=600,
    bgcolor="grey",
    content=gesture_container,
)
def main(page:ft.Page):
    page.add(container)

if __name__ == "__main__":
    ft.app(target=main)

To reproduce

Use the code above. When you exit the GestureDetector zone, an error will be thrown.

Tested in v0.23.2 : KO Tested in v0.23.1 : OK

error : Task exception was never retrieved future: <Task finished name='Task-83' coro=<run_socket_server..on_event() done, defined at C:_DEV__bibliotheque.venv\Lib\site-packages\flet_runtime\app.py:217> exception=KeyError('dx')> Traceback (most recent call last): File "C:_DEV__bibliotheque.venv\Lib\site-packages\flet_runtime\app.py", line 219, in on_event await conn.sessions[e.sessionID].on_event_async( File "C:_DEV__bibliotheque.venv\Lib\site-packages\flet_core\page.py", line 905, in on_event_async await handler(ce) File "C:_DEV__bibliotheque.venv\Lib\site-packages\flet_core\event_handler.py", line 18, in fn ce = self.result_converter(e) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:_DEV\bibliotheque.venv\Lib\site-packages\flet_core\gesture_detector.py", line 277, in self.__on_exit = EventHandler(lambda e: HoverEvent(e)) ^^^^^^^^^^^^^ File "C:_DEV\bibliotheque.venv\Lib\site-packages\flet_core\gesture_detector.py", line 818, in init self.delta_x: Optional[float] = d["dx"] ~^^^^^^ KeyError: 'dx'

Expected behavior

No response

Screenshots

No response

Operating System

Windows

Operating system details

windows 11

Flet version

0.23.2

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Additional details

No response

shrpow commented 3 months ago

have same issue with OnScrollEvent

ndonkoHenri commented 3 months ago

Sorry for that! Issue has been fixed in https://github.com/flet-dev/flet/pull/3551

ndonkoHenri commented 2 months ago

Issue has been fixed. Give it a try by installing the latest Flet prerelease: pip install flet --pre (https://pypi.org/project/flet/#history) Report if the issue persists.