ListView and GridView within a ExpansionTile are not scrollable
Duplicate Check
- [x] I have searched the opened issues and there are no duplicates
Describe the bug
Hello, I noticed that when a ListView or a GridView is placed within the list of controls of an ExpansionTIle, they are not scrollable. Their content simply extend over the screen size.
Code sample
Code
import flet as ft
def main(page: ft.Page):
page.title = "Scrollable ExpansionTile Example"
# Create a ListView to hold the content of the ExpansionTile
list_view = ft.ListView(
expand=1, # Allow the ListView to expand and fill available space
spacing=10, # Space between items
padding=20, # Padding around the ListView
auto_scroll=True # Automatically scroll to the end when new items are added
)
# Add multiple items to the ListView
for i in range(1, 101): # Example: 100 items
list_view.controls.append(ft.Text(f"Item {i}"))
# Create an ExpansionTile and add the ListView as its content
expansion_tile = ft.ExpansionTile(
title=ft.Text("Expandable Section"),
controls=[list_view],
expand=True
)
# Add the ExpansionTile to the page
page.add(expansion_tile)
# Run the Flet app
ft.app(main)
To reproduce
- Run the code above:
flet run --web - Click on the arrow on the right in order to expand the tile
- Try to scroll the list
Expected behavior
I expect the ListView to be scrollable.
Screenshots / Videos
Captures
Operating System
Linux
Operating system details
Ubuntu 20.04
Flet version
0.24.0
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
Logs
[Paste your logs here]
Additional details
No response
It happens because the ListView attempts to expand infinitely (have unbounded height constraints).
Here are some suggestions:
-
give the
ListViewa fixed height:Details
import flet as ft def main(page: ft.Page): page.add( ft.ExpansionTile( title=ft.Text("Expandable Section"), controls=[ ft.ListView( height=300, spacing=10, padding=20, auto_scroll=True, controls=[ft.Text(f"Item {i}") for i in range(1, 101)], ), ], ) ) ft.app(main) -
set
page.scroll- LV props likeauto_scrollwon't have a visible effect here though:Details
import flet as ft def main(page: ft.Page): page.scroll = True page.add( ft.ExpansionTile( title=ft.Text("Expandable Section"), controls=[ ft.ListView( spacing=10, padding=20, auto_scroll=True, controls=[ft.Text(f"Item {i}") for i in range(1, 101)], ), ], ) ) ft.app(main)
However in case of using a Container it works:
import flet as ft
def main(page: ft.Page):
page.add(
ft.Container(
content=
ft.ListView(
spacing=10,
padding=20,
auto_scroll=True,
controls=[ft.Text(f"Item {i}") for i in range(1, 101)],
),
expand=True,
)
)
ft.app(main)
It happens because the
ListViewattempts to expand infinitely (have unbounded height constraints).Here are some suggestions:
give the
ListViewa fixed height: Detailsimport flet as ft
def main(page: ft.Page): page.add( ft.ExpansionTile( title=ft.Text("Expandable Section"), controls=[ ft.ListView( height=300, spacing=10, padding=20, auto_scroll=True, controls=[ft.Text(f"Item {i}") for i in range(1, 101)], ), ], ) )
ft.app(main)
set
page.scroll- LV props likeauto_scrollwon't have a visible effect here though: Detailsimport flet as ft
def main(page: ft.Page): page.scroll = True
page.add( ft.ExpansionTile( title=ft.Text("Expandable Section"), controls=[ ft.ListView( spacing=10, padding=20, auto_scroll=True, controls=[ft.Text(f"Item {i}") for i in range(1, 101)], ), ], ) )ft.app(main)
Perfect, it works! Thank you!
However in case of using a Container it works
Yh, Container is not a scrollable. The issue here is caused by having a scrollable in another scrollable.