Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions sdk/python/packages/flet-core/src/flet_core/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ class Chip(ConstrainedControl):
Example:
```
import flet as ft


def main(page: ft.Page):
def save_to_favorites_clicked(e):
e.control.label.value = "Saved to favorites"
e.control.leading = ft.Icon(ft.icons.FAVORITE_OUTLINED)
e.control.disabled = True
page.update()

def open_google_maps(e):
page.launch_url("https://maps.google.com")
page.update()

save_to_favourites = ft.Chip(
label=ft.Text("Save to favourites"),
leading=ft.Icon(ft.icons.FAVORITE_BORDER_OUTLINED),
Expand All @@ -44,16 +44,16 @@ def open_google_maps(e):
autofocus=True,
on_click=save_to_favorites_clicked,
)

open_in_maps = ft.Chip(
label=ft.Text("9 min walk"),
leading=ft.Icon(ft.icons.MAP_SHARP),
bgcolor=ft.colors.GREEN_200,
on_click=open_google_maps,
)

page.add(ft.Row([save_to_favourites, open_in_maps]))

ft.app(target=main)
```

Expand All @@ -64,6 +64,7 @@ def open_google_maps(e):

def __init__(
self,
label: Control,
ref: Optional[Ref] = None,
width: OptionalNumber = None,
height: OptionalNumber = None,
Expand Down Expand Up @@ -94,7 +95,6 @@ def __init__(
# Specific
#
autofocus: Optional[bool] = None,
label: Control = None,
leading: Optional[Control] = None,
bgcolor: Optional[str] = None,
selected: Optional[bool] = False,
Expand Down Expand Up @@ -208,7 +208,7 @@ def padding(self, value: PaddingValue):
# selected
@property
def selected(self) -> Optional[bool]:
return self._get_attr("selected")
return self._get_attr("selected", data_type="bool", def_value=False)

@selected.setter
def selected(self, value: Optional[bool]):
Expand Down