Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ListView cannot be built in UserControl. Once the ListView is added, other controls will not be displayed #331

Closed
modaye opened this issue Sep 15, 2022 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@modaye
Copy link
Contributor

modaye commented Sep 15, 2022

class Sidebar(UserControl):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # self.menu = ListView(expand=1, spacing=10, padding=10, auto_scroll=True, )

    def build(self):
        menu = ListView(
            controls=[
                Text("Select a box", color="#232324"),
            ]
        )
        return Column(
            controls=[
                Text("Sidebar"),
                menu
            ]
        )


def main(page: Page):
    page.title = "Auto-scrolling ListView"
    # page.show_semantics_debugger = True
    sidebar = Sidebar()
    page.add(sidebar)
    page.update()


flet.app(target=main)

The above is a minimum example

@FeodorFitsner
Copy link
Contributor

A working example using expand:

import flet
from flet import Column, ListView, Page, Text, UserControl


class Sidebar(UserControl):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # self.menu = ListView(expand=1, spacing=10, padding=10, auto_scroll=True, )

    def build(self):
        self.expand = True
        menu = ListView(
            controls=[
                Text("Select a box", color="#232324"),
            ],
            expand=True,
        )
        return Column(controls=[Text("Sidebar"), menu])


def main(page: Page):
    page.title = "Auto-scrolling ListView"
    sidebar = Sidebar()
    page.add(sidebar)


flet.app(target=main)

@FeodorFitsner
Copy link
Contributor

Internal notes: We should prevent user errors like that by checking outer bounds for ListView and other scrollable controls.
The following error is generated on Flutter side:

════════ Exception caught by rendering library ═════════════════════════════════
The following assertion was thrown during performResize():
Vertical viewport was given unbounded height.

Viewports expand in the scrolling direction to fill their container. In this case, a vertical viewport was given an unlimited amount of vertical space in which to expand. This situation typically happens when a scrollable widget is nested inside another scrollable widget.

If this widget is always nested in a scrollable widget there is no need to use a viewport because there will always be enough vertical space for the children. In this case, consider using a Column or Wrap instead. Otherwise, consider using a CustomScrollView to concatenate arbitrary slivers into a single scrollable.

The relevant error-causing widget was
ListView

@FeodorFitsner FeodorFitsner added the bug Something isn't working label Sep 15, 2022
@modaye
Copy link
Contributor Author

modaye commented Sep 16, 2022

ok, how get the error in flet

@FeodorFitsner
Copy link
Contributor

We have to implement that, not you.

@hololeo
Copy link

hololeo commented Sep 16, 2022

"Vertical viewport was given unbounded height."

This is why i think getting intrinsic data about the widget at runtime is necessary. flet is not providing enough container properties for flutter to compute layouts (unless they are explicitly set of course) an api call should be provided to have flet query the dart side for all the properties in that widget and the tree. hope that makes sense

@FeodorFitsner FeodorFitsner added this to the Controls-S2 milestone Sep 20, 2022
@FeodorFitsner FeodorFitsner added the status: working on it Working on a fix for the issue label Oct 8, 2022
@FeodorFitsner FeodorFitsner removed the status: working on it Working on a fix for the issue label Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants