Skip to content

[Question] Navigating causes Controls error #1660

Answered by FeodorFitsner
doug-benn asked this question in Q&A
Discussion options

You must be logged in to vote

Fixed code:

import flet as ft


class Store(ft.UserControl):
    def stuff(self, e):
        print("Hello")
        self.controls.append(ft.Text("Hello"))
        self.update()

    def build(self):
        return ft.ElevatedButton("Store Button", on_click=self.stuff)


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_VARIANT
                    ),
                    ft.ElevatedButton(
                        "Visit Store", on_click=

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by doug-benn
Comment options

You must be logged in to vote
4 replies
@FeodorFitsner
Comment options

@doug-benn
Comment options

@FeodorFitsner
Comment options

@doug-benn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
2 participants