Routing: View Pop function showing blank screen
Duplicate Check
- [x] I have searched the opened issues and there are no duplicates
Describe the bug
On triggering the viewpop() function, the screen is left blank. And this started in current version 0.28.3
Code sample
From flet Official Routing Docs
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.ElevatedButton("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.ElevatedButton("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.app(main, view=ft.AppView.WEB_BROWSER
To reproduce
Run the above code and trigger the viewpop()
Expected behavior
Blank screen
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
11
Flet version
0.28.3
Regression
Yes, it used to work in a previous Flet version (please specify the version in additional details)
Suggestions
No response
Logs
Logs
[Paste your logs here]
Additional details
I used it in 0.27.5 but it was working well but when I switched to 0.28.3 it appeared.
What do you mean by "trigger the viewpop()"?
On clicking the back button in the app bar, it is supposed to take me back to the last view but instead it shows a blank screen without any view. Run the above code to reproduce the bug
@FeodorFitsner and @ndonkoHenri Can u please work on my issue. Please...
I have migrated recently to latest pre-release Version: 0.70.0.dev6491.
And after migration I got DeprecationWarning: go() is deprecated since version 0.70.0. Use push_route() instead.
I have tried push_route() example in the doc push_route but having blank screen.
Please let me know if not related and I will create separate issue
Can you give a repro code please?
Please find below the code. push_route example in the doc.
https://docs.flet.dev/controls/page/?h=push_route#flet.Page.push_route
import flet as ft
import asyncio
def main(page: ft.Page):
page.title = "Push Route Example"
def route_change(e):
page.views.clear()
page.views.append(
ft.View(
route="/",
controls=[
ft.AppBar(title=ft.Text("Flet app")),
ft.ElevatedButton(
"Visit Store",
on_click=lambda _: asyncio.create_task(
page.push_route("/store")
),
),
],
)
)
if page.route == "/store":
page.views.append(
ft.View(
route="/store",
can_pop=True,
controls=[
ft.AppBar(title=ft.Text("Store")),
ft.ElevatedButton(
"Go Home",
on_click=lambda _: asyncio.create_task(
page.push_route("/")
),
),
],
)
)
async def view_pop(e):
page.views.pop()
top_view = page.views[-1]
await page.push_route(top_view.route)
page.on_route_change = route_change
page.on_view_pop = view_pop
ft.run(main)