flet icon indicating copy to clipboard operation
flet copied to clipboard

on_scroll in 0.23.2 doesnt work (ERROR Task exception was never retrieved. Key Error 'sd' etc)

Open Broys42 opened this issue 7 months ago • 2 comments

Duplicate Check

  • [X] I have searched the opened issues and there are no duplicates

Describe the bug

In new version flet on_scroll in any controls doesnt work

Code

Code from doc - https://flet.dev/docs/controls/column/#scroll_tooffset-delta-key-duration-curve


import threading
import flet as ft

class State:
    i = 0

s = State()
sem = threading.Semaphore()

def main(page: ft.Page):
    def on_scroll(e: ft.OnScrollEvent):
        if e.pixels >= e.max_scroll_extent - 100:
            if sem.acquire(blocking=False):
                try:
                    for i in range(0, 10):
                        cl.controls.append(ft.Text(f"Text line {s.i}", key=str(s.i)))
                        s.i += 1
                    cl.update()
                finally:
                    sem.release()

    cl = ft.Column(
        spacing=10,
        height=200,
        width=200,
        scroll=ft.ScrollMode.ALWAYS,
        on_scroll_interval=0,
        on_scroll=on_scroll,
    )
    for i in range(0, 50):
        cl.controls.append(ft.Text(f"Text line {s.i}", key=str(s.i)))
        s.i += 1

    page.add(ft.Container(cl, border=ft.border.all(1)))

ft.app(main)

To reproduce

Try this code. I have exact problem in my projects

Expected behavior

No response

Screenshots

No response

Operating System

Windows

Operating system details

11 23H2

Flet version

0.23.2

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Additional details

No response

Broys42 avatar Jun 28 '24 10:06 Broys42