flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.59k stars 454 forks source link

Unknown control: navigationdrawer #4098

Closed Muddassir-Farooq-official closed 1 month ago

Muddassir-Farooq-official commented 1 month ago

Duplicate Check

Describe the bug

facing an issue Unknown control: navigationdrawer when return navigation drawer using class build function

Code sample

Code ```python import flet as ft class Navbar_Control(ft.UserControl): def __init__(self): super().__init__() self.theme_color = ft.colors.BLUE_900 def build(self): return ft.NavigationDrawer( controls=[ ft.Container(height=12), ft.Container( content=ft.Column( [ #ft.Text(value="AL-BURAQ",color='#084d0d') ], horizontal_alignment='center' ), width=200,alignment=ft.alignment.center ), #ft.Container(height=22), ft.ListTile(title=ft.Text("Dashboard",color=self.theme_color),leading=ft.Icon(ft.icons.DASHBOARD),icon_color=self.theme_color), ft.ExpansionTile( title=ft.ListTile(title=ft.Text("Admission",color=self.theme_color),leading=ft.Icon(ft.icons.PERSON),icon_color=self.theme_color,bgcolor=''), affinity=ft.TileAffinity.PLATFORM, maintain_state=True, controls=[ ft.ListTile(title=ft.Text("New Admission",color=self.theme_color)), ], ), ft.ExpansionTile( title=ft.ListTile(title=ft.Text("Manage Students",color=self.theme_color),leading=ft.Icon(ft.icons.PERSON),icon_color=self.theme_color,bgcolor=''), affinity=ft.TileAffinity.PLATFORM, maintain_state=True, controls=[ ft.ListTile(title=ft.Text("Students List",color=self.theme_color)), ], ), ft.ExpansionTile( title=ft.ListTile(title=ft.Text("Manage Classes",color=self.theme_color),leading=ft.Icon(ft.icons.PERSON),icon_color=self.theme_color,bgcolor=''), affinity=ft.TileAffinity.PLATFORM, maintain_state=True, controls=[ ft.ListTile(title=ft.Text("New Class",color=self.theme_color),on_click= lambda _: self.page.go("New_class")), ], ), ft.ExpansionTile( title=ft.ListTile(title=ft.Text("Manage Programs",color=self.theme_color),leading=ft.Icon(ft.icons.PERSON),icon_color=self.theme_color,bgcolor=''), affinity=ft.TileAffinity.PLATFORM, maintain_state=True, controls=[ ft.ListTile(title=ft.Text("New Program",color=self.theme_color)), ], ), ft.ListTile(title=ft.Text("Logout",color=self.theme_color),leading=ft.Icon(ft.icons.LOGOUT),icon_color=self.theme_color), ], bgcolor='white', #indicator_color=ft.colors.RED, #indicator_shape=ft.RoundedRectangleBorder(radius=5), ) ```

To reproduce

i want to display navigationdrawer

Expected behavior

No response

Screenshots / Videos

Captures ![image](https://github.com/user-attachments/assets/25021d42-7552-4747-8608-8bdea34e656f)

Operating System

Windows

Operating system details

Windows 10

Flet version

0.24.1

Regression

No, it isn't

Suggestions

No response

Logs

Logs ```console C:\Users\Muddassir Farooq\Desktop\OOP\main.py:37: DeprecationWarning: window_always_on_top is deprecated in version 0.23.0 and will be removed in version 0.26.0. Use Page.window.always_on_top instead. page.window_always_on_top = True Future exception was never retrieved future: Traceback (most recent call last): File "C:\Users\Muddassir Farooq\AppData\Local\Programs\Python\Python312\Lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Muddassir Farooq\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet_core\page.py", line 944, in wrapper handler(*args) File "C:\Users\Muddassir Farooq\Desktop\OOP\views.py", line 43, in leading=ft.IconButton(icon=ft.icons.MENU,icon_color='white',on_click= lambda _: page.open(navbar)), ^^^^^^^^^^^^^^^^^ File "C:\Users\Muddassir Farooq\AppData\Local\Programs\Python\Python312\Lib\site-packages\flet_core\page.py", line 1409, in open raise ValueError("control has no open attribute") ValueError: control has no open attribute ```

Additional details

No response