Skip to content

bug: [V1] Control with key: RuntimeError: Frozen controls cannot be updated. #5799

@3mora2

Description

@3mora2

Duplicate Check

Describe the bug

failed update control, when append control with key to existing controls

Code sample

Code
import flet as ft


def main(page):
    def item(key) -> ft.Container:
        def change_bgcolor(e: ft.Event[ft.Container]):
            e.control.bgcolor = ft.Colors.GREY

        return ft.Container(
            ft.Text(key),
            width=100, height=100, bgcolor=ft.Colors.GREEN,
            on_click=change_bgcolor,
            key=ft.ScrollKey(key),  # Work Fine Without Key
        )

    def add_new():
        grid.controls.append(item(len(grid.controls)))

    grid = ft.ResponsiveRow(
        controls=[item(0), item(1), ]
    )
    page.add(ft.Column([
        ft.Row([ft.Button("New", on_click=add_new)]),
        grid
    ]))


if __name__ == '__main__':
    ft.run(
        main=main
    )

item with key > 1 not update

To reproduce

  • run code
  • click add new
  • click on Container to change bgcolor

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

win 11

Flet version

flet[all]>=0.70.0.dev6561

Regression

No, it isn't

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions