Skip to content

View

Inherits: ScrollableControl, LayoutControl

View is the top most container for all other controls.

A root view is automatically created when a new user session started. From layout perspective the View represents a Column control, so it has a similar behavior and shares same properties.

Properties

Events

Methods

Properties#

appbar #

appbar: AppBar | CupertinoAppBar | None = None

An AppBar control to display at the top of the Page.

bgcolor #

bgcolor: ColorValue | None = None

Background color of the view.

bottom_appbar #

bottom_appbar: BottomAppBar | None = None

A BottomAppBar control to display at the bottom of the Page.

can_pop #

can_pop: bool = True

controls #

controls: list[BaseControl] = field(default_factory=list)

A list of controls to display.

Example

For example, to add a new control to a page:

page.controls.append(ft.Text("Hello!"))
page.update()

or to get the same result as above using page.add() shortcut method:

page.add(ft.Text("Hello!"))

To remove the top most control on the page:

page.controls.pop()
page.update()

decoration #

decoration: BoxDecoration | None = None

The background decoration.

drawer #

drawer: NavigationDrawer | None = None

A NavigationDrawer control to display as a panel sliding from the start edge of the view.

end_drawer #

end_drawer: NavigationDrawer | None = None

A NavigationDrawer control to display as a panel sliding from the end edge of the view.

floating_action_button #

floating_action_button: FloatingActionButton | None = None

A FloatingActionButton control to display on top of Page content.

floating_action_button_location #

floating_action_button_location: (
    FloatingActionButtonLocation | OffsetValue | None
) = None

Describes position of floating_action_button

foreground_decoration #

foreground_decoration: BoxDecoration | None = None

The foreground decoration.

horizontal_alignment #

horizontal_alignment: CrossAxisAlignment = START

How the child Controls should be placed horizontally.

navigation_bar #

navigation_bar: (
    NavigationBar | CupertinoNavigationBar | None
) = None

A navigation bar (NavigationBar or CupertinoNavigationBar) control to display at the bottom of the Page.

padding #

padding: PaddingValue | None = field(
    default_factory=lambda: all(10)
)

A space between page contents and its edges.

route #

route: str | None = field(default_factory=lambda: '/')

View's route - not currently used by Flet framework, but can be used in a user program to update Page.route when a view popped.

spacing #

spacing: Number = 10

The vertical spacing between controls on the Page.

Note

Has effect only when vertical_alignment is set to MainAxisAlignment.START, MainAxisAlignment.END, or MainAxisAlignment.CENTER.

vertical_alignment #

vertical_alignment: MainAxisAlignment = START

Defines how the child controls should be placed vertically.

Events#

on_confirm_pop #

on_confirm_pop: ControlEventHandler[View] | None = None

Methods#

confirm_pop #

confirm_pop(should_pop: bool) -> None