Skip to content
Discussion options

You must be logged in to vote

It's all happening because you are adding the same control to the page again. All controls on a page should have unique IDs. That ID is assigned when control is added to a page. When you add the same control over and over, by reference, all those references point to the same control with the same ID. A correct way is adding a new control instance every time you click the button:

import flet as ft

def main(page):
    lview = ft.ListView(auto_scroll=True)

    def expand(e):
        print(f"Just Before Addition: {lview.controls=}")
        lview.controls.append(ft.ListTile(title=ft.Text("Test")))
        page.update()
        print(f"After Addition: {lview.controls=} \n")

    page.add(
  …

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
2 replies
@FeodorFitsner
Comment options

@ndonkoHenri
Comment options

Comment options

You must be logged in to vote
8 replies
@noob-infinity
Comment options

@ndonkoHenri
Comment options

@noob-infinity
Comment options

@FeodorFitsner
Comment options

Answer selected by noob-infinity
@ndonkoHenri
Comment options

@noob-infinity
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants