flet icon indicating copy to clipboard operation
flet copied to clipboard

`SliverListView` and `SliverGridView` controls

Open ndonkoHenri opened this issue 2 months ago • 1 comments

Closes #3427 and #3428

Test Code

from time import sleep
import flet as ft


def main(page: ft.Page):
    lv = ft.SliverListView(expand=1, spacing=10, padding=20)

    count = 1

    for i in range(0, 60):
        lv.controls.append(ft.Text(f"Line {count}"))
        count += 1

    page.add(lv)

    for i in range(0, 60):
        sleep(1)
        lv.controls.append(ft.Text(f"Line {count}"))
        count += 1
        page.update()


ft.app(target=main)
import flet as ft


def main(page: ft.Page):
    grid = ft.SliverGridView(
        expand=1,
        runs_count=5,
        # max_extent=50,
        child_aspect_ratio=1,
        spacing=15,
        run_spacing=10,
        controls=[
            ft.Container(
                content=ft.Text(
                    f"Item {i}",
                    weight=ft.FontWeight.BOLD,
                    overflow=ft.TextOverflow.CLIP,
                ),
                alignment=ft.alignment.center,
                bgcolor=ft.colors.random_color(),
                border_radius=ft.border_radius.all(10),
            )
            for i in range(0, 60)
        ],
    )

    page.add(grid)


ft.app(target=main)

Summary by Sourcery

This pull request introduces the SliverListView control, allowing for the creation of scrollable lists with customizable spacing, padding, and orientation. The necessary widget creation logic has been updated to support this new control.

  • New Features:
    • Introduced SliverListView control, a scrollable list of controls arranged linearly, with support for horizontal and vertical scrolling, spacing, padding, and other customization options.
  • Enhancements:
    • Added SliverListViewControl to the widget creation logic in create_control.dart to support the new SliverListView control.

ndonkoHenri avatar Jun 07 '24 01:06 ndonkoHenri