flet-dev / flet-dev/flet

Performance when visible is False

Open
#712 13 comments 0 reactions 1 assignee View on GitHub

@FeodorFitsner is already working on this.

Since Sep 29, 2025.

bug has reproducible steps performance
Dominant language
Python
Stars
17k
Forks
694
Avg merge
1d 14h
Merged PRs (30d)
33

Description

Two examples here, one with 100x100 container on stack ( only 20x20 are visible ) and the other with just 20x20.

https://user-images.githubusercontent.com/24403606/207773382-b7931b72-0745-43de-b1cd-dae32fa3f629.mov

https://user-images.githubusercontent.com/24403606/207773357-ee7101ca-8ba4-48b4-ab19-64b01e6053f5.mov

here is the code

for 100x100 ( only 20x20 visible )

from jupyflow import Cell, OutputArea
from flet import *
import random
import flet as ft


def main(page: ft.Page):
    page.title = "GridView Example"
    page.theme_mode = ft.ThemeMode.DARK
    # page.padding = 50
    page.update()

    container_grid = []
    for y in range(100):
        for x in range(100):
            container_grid.append(
                Container(
                    expand=False,
                    width=50,
                    height=50,
                    bgcolor=colors.LIGHT_BLUE_50,
                    border_radius=0,
                    margin=0,
                    padding=0,
                    top=y * (50 + 1),
                    left=x * (50 + 1),
                    clip_behavior=ClipBehavior.NONE,
                    visible=True if y < 20 and x < 20 else False,
                )
            )

    def on_pan_update(e: ft.DragUpdateEvent):
        stack_a.top = stack_a.top + e.delta_y
        stack_a.left = stack_a.left + e.delta_x
        stack_a.update()

    stack_a = Stack(
        controls=container_grid
        + [
            GestureDetector(
                on_pan_update=on_pan_update,
            )
        ],
        width=5000,
        height=5000,
        top=-50,
        left=-50,
    )
    stack_b = Stack(
        controls=[stack_a],
        width=2000,
        height=1500,
    )

    page.add(stack_b)

    page.update()


ft.app(target=main, view=ft.WEB_BROWSER)

for 20x20 visible

from jupyflow import Cell, OutputArea
from flet import *
import random
import flet as ft


def main(page: ft.Page):
    page.title = "GridView Example"
    page.theme_mode = ft.ThemeMode.DARK
    # page.padding = 50
    page.update()

    container_grid = []
    for y in range(20):
        for x in range(20):
            container_grid.append(
                Container(
                    expand=False,
                    width=50,
                    height=50,
                    bgcolor=colors.LIGHT_BLUE_50,
                    border_radius=0,
                    margin=0,
                    padding=0,
                    top=y * (50 + 1),
                    left=x * (50 + 1),
                    clip_behavior=ClipBehavior.NONE,
                    visible=True if y < 20 and x < 20 else False,
                )
            )

    def on_pan_update(e: ft.DragUpdateEvent):
        stack_a.top = stack_a.top + e.delta_y
        stack_a.left = stack_a.left + e.delta_x
        stack_a.update()

    stack_a = Stack(
        controls=container_grid
        + [
            GestureDetector(
                on_pan_update=on_pan_update,
            )
        ],
        width=5000,
        height=5000,
        top=-50,
        left=-50,
    )
    stack_b = Stack(
        controls=[stack_a],
        width=2000,
        height=1500,
    )

    page.add(stack_b)

    page.update()


ft.app(target=main, view=ft.WEB_BROWSER)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.