Skip to content

bug: When build folder exists, the error "Unknown control: PageView" occurs #6201

@Creeper19472

Description

@Creeper19472

Duplicate Check

Describe the bug

This issue only occurs under the following stringent conditions:

  1. The working directory is in the root directory of a classic project created by flet create (with src as its subdirectory);
  2. flet build windows must have been run at least once (other platforms have not been tested), and a build folder must have been generated in the root directory.

In short: When the above conditions are met, ft.PageView control will not display correctly and will be replaced with the error message described in the title.

Also noteworthy is the unusual change in the display window title: it is now the name of the project folder instead of the usual Flet.

Code sample

Code
import flet as ft


def main(page: ft.Page):
    page.padding = 0

    page.add(
        ft.PageView(
            expand=True,
            viewport_fraction=0.9,
            on_change=lambda e: print(f"Currently viewing page {int(e.data)}"),
            selected_index=1,
            horizontal=True,
            controls=[
                ft.Container(
                    bgcolor=ft.Colors.INDIGO_400,
                    content=ft.Column(
                        alignment=ft.MainAxisAlignment.CENTER,
                        horizontal_alignment=ft.CrossAxisAlignment.CENTER,
                        controls=[
                            ft.Text("Welcome", size=40, weight=ft.FontWeight.BOLD),
                            ft.Text("Swipe to see what PageView can do."),
                        ],
                    ),
                ),
                ft.Container(
                    bgcolor=ft.Colors.PINK_300,
                    content=ft.Column(
                        alignment=ft.MainAxisAlignment.CENTER,
                        horizontal_alignment=ft.CrossAxisAlignment.CENTER,
                        controls=[
                            ft.Icon(ft.Icons.ANIMATION, size=72),
                            ft.Text(
                                "Viewport fraction lets you peek at the next slide."
                            ),
                        ],
                    ),
                ),
                ft.Container(
                    bgcolor=ft.Colors.TEAL_300,
                    content=ft.Column(
                        alignment=ft.MainAxisAlignment.CENTER,
                        horizontal_alignment=ft.CrossAxisAlignment.CENTER,
                        controls=[
                            ft.Icon(ft.Icons.TOUCH_APP, size=72),
                            ft.Text("Use on_change to respond to page swipes."),
                        ],
                    ),
                ),
            ],
        ),
    )


if __name__ == "__main__":
    ft.run(main)

To reproduce

The following steps can reliably reproduce this issue.

  1. Create a folder that can use any common name; here, we specify test.
  2. Create a virtual environment at .venv. This example uses uv to create virtual environments and manage packages.
  3. Run flet create. Then edit pyproject.toml and add the following line:
[tool.uv]
prerelease = "allow"
  1. Run uv sync --upgrade.
  2. Create test.py. The content is consistent with the sample code provided in this issue, and it is also obtained from the official documentation. The location of this file will not affect the final result.
  3. Run test.py from the project root directory. It should be able to work normally at this time.
  4. Run flet build windows.
  5. Run test.py again. The aforementioned error will now be observed, and the window title will also change to the name of the project folder.

Expected behavior

PageView displays correctly

Screenshots / Videos

Captures Image

Operating System

Windows

Operating system details

Windows 11 (26200.7840)

Flet version

0.80.6.dev7651

Regression

No, it isn't

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions