Skip to content
Discussion options

You must be logged in to vote

Modify the line in the for loop as follows:

lv.controls.append(FilledButton(text=f"# {i}", data=i, on_click=lambda e: show_item(e.control.data)))

All Flet controls have a data property, which takes any python data type (int, list, dict etc).
So, you store the i in there, and get it back using e.control.data.

Let me know if it works as expected after this fix.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@AaronCatolico
Comment options

@ndonkoHenri
Comment options

@bobwatcherx
Comment options

@ndonkoHenri
Comment options

Answer selected by AaronCatolico
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