NavigationRail
is not shown if expand=True
of parent is set in build
method
#1811
-
I hereby solemnly swear that I have read #287 and #303 and that what I am describing is, to my understanding, not covered by the solutions provided therein. The following code results in an error, even though I am using a import flet as ft
class AppView(ft.UserControl):
def __init__(self):
super().__init__()
self.navigation_rail = ft.NavigationRail(
destinations=[
ft.NavigationRailDestination(
icon=ft.icons.START,
label="one destination"
),
ft.NavigationRailDestination(
icon=ft.icons.STAR,
label="another destination"
)
],
on_change=lambda event: print("Selected destination:", event.control.selected_index),
)
def build(self):
return ft.Row(
controls=[
self.navigation_rail
],
expand=True
)
def main(page: ft.Page):
app_view = AppView()
page.add(app_view)
ft.app(target=main) However, when I change def main(page: ft.Page):
app_view = AppView()
page.add(ft.Row([app_view], expand=True)) and def main(page: ft.Page):
app_view = AppView()
page.add(ft.Row([app_view.navigation_rail], expand=True)) work just fine. These also work if I replace Using an explicit height restriction in the class AppView(ft.UserControl):
...
def build(self):
return ft.Row(
controls=[
self.navigation_rail
],
height=200
)
def main(page: ft.Page):
app_view = AppView()
page.add(app_view)
ft.app(target=main) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Why not to inherit from |
Beta Was this translation helpful? Give feedback.
Why not to inherit from
Row
directly, not fromUserControl
?