Skip to content

Unique Chip in row #2614

Answered by ndonkoHenri
stephen-lspd asked this question in Q&A
Feb 12, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can do that by looping through all the chips and deselecting all (except the pressed chip). Example below:

import flet as ft


def main(page: ft.Page):
    page.theme_mode = ft.ThemeMode.LIGHT

    def amenity_selected(e):
        for i in amenity_chips:
            if i != e.control:  # if this is not the pressed chip,
                i.selected = False  # deselect it
        page.update()

    title = ft.Row([ft.Icon(ft.icons.HOTEL_CLASS), ft.Text("Amenities")])
    amenities = ["Washer / Dryer", "Ramp access", "Dogs OK", "Cats OK", "Smoke-free"]
    amenity_chips = []

    for amenity in amenities:
        amenity_chips.append(
            ft.Chip(
                label=ft.Text(ame…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stephen-lspd
Comment options

Answer selected by stephen-lspd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2612 on February 13, 2024 01:48.