Skip to content

ControlEvent.data should be of type Optional[str] and default to None #4786

Open
@ndonkoHenri

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.

class ControlEvent(Event):
def __init__(self, target: str, name: str, data: str, control, page):
Event.__init__(self, target=target, name=name, data=data)

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

enhancementImprovement/Optimization

Type

No type

Projects

  • Status

    🆕 New

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions