Skip to content

bug: The properties of the ft.context.page are not updated in time #5839

@aigcst

Description

@aigcst

Duplicate Check

Describe the bug

When the window size changes, the ft.context.page.window cannot follow the change in time

Code sample

import flet as ft
import flet.canvas as cv


def main(page: ft.Page):
    v_text = ft.Text()

    def on_resize(e):
        v_text.value = (
            f"{e}\n, width={e.control.width}, height={e.control.height}, window_width={ft.context.page.window.width}"
        )
        page.update()

    page.add(
        v_text,
        cv.Canvas(
            width=float('inf'),
            height=600,
            shapes=[
                cv.Circle(x=100, y=100, radius=50),
            ],
            on_resize=on_resize,
        ),
    )


ft.run(main)

To reproduce

Steps to reproduce:
1.Run the repro code.
2.Drag the edge of the window to zoom the window. When it moves quickly, ft.context.page.window.width will not be updated in time.

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 11

Flet version

0.70.0.dev6707

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    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