-
Notifications
You must be signed in to change notification settings - Fork 605
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Duplicate Check
- I have searched the opened issues and there are no duplicates
Describe the bug
Navigation and Routing
- Just need to add arg on ft.View
- on launch, it doesn't show the " / " view, have to go to "/store" an them back to show " / " view.
import flet as ft
def main(page: ft.Page):
page.title = "Routes Example"
def route_change(route):
page.views.clear()
page.views.append(
ft.View(
"/",
[
ft.AppBar(title=ft.Text("Flet app"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST),
ft.Button("Visit Store", on_click=lambda _: page.go("/store")),
],
)
)
if page.route == "/store":
page.views.append(
ft.View(
"/store",
[
ft.AppBar(title=ft.Text("Store"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST),
ft.Button("Go Home", on_click=lambda _: page.go("/")),
],
)
)
page.update()
def view_pop(view):
page.views.pop()
top_view = page.views[-1]
page.go(top_view.route)
page.on_route_change = route_change
page.on_view_pop = view_pop
page.go(page.route)
ft.run(main, view=ft.AppView.WEB_BROWSER)Solution:
Add arg on
ft.View(
route="/store",
controls=[
ft.AppBar(title=ft.Text("Store"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST),
ft.Button("Go Home", on_click=lambda _: page.go("/")),
],
)Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working