ControlEvent.data
should be of type Optional[str]
and default to None
#4786
Open
Description
At the moment ControlEvent.data
(or precisely Event.data
) is of type string and defaults to an empty string. This is misleading as one could think that's an actual data which was passed, whereas, seeing None
will be a good indication that nothing was passed.
flet/sdk/python/packages/flet/src/flet/core/control_event.py
Lines 4 to 6 in cc998cd
Test Code
import flet as ft
def main(page: ft.Page):
page.add(
ft.ElevatedButton("Hello", on_click=lambda e: print(f"Button clicked: {e.data!r}")), # same with on_focus, on_blur etc
)
ft.app(main)
Metadata
Assignees
Labels
Type
Projects
Status
🆕 New