flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
9.96k stars 392 forks source link

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

Open Broys42 opened 1 week ago

Broys42 commented 1 week ago

Duplicate Check

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 commented 1 week ago

I changed all the on_scroll methods and ScrollableControl class from 0.19.0 to 0.23.2 and everything started working

handouy commented 6 days ago

I rolled back the flet version to 0.23.1 to work normally