Skip to main content

View

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.

Inherits: ScrollableControl, LayoutControl

Properties

Events

  • on_confirm_pop - An event handler that is called when the view is about to be popped.

Methods

Properties

appbarclass-attributeinstance-attribute

appbar: AppBar | CupertinoAppBar | None = None

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

bgcolorclass-attributeinstance-attribute

bgcolor: ColorValue | None = None

Background color of the view.

bottom_appbarclass-attributeinstance-attribute

bottom_appbar: BottomAppBar | None = None

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

can_popclass-attributeinstance-attribute

can_pop: bool = True

Whether the view can be popped.

controlsclass-attributeinstance-attribute

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

A list of controls to display.

decorationclass-attributeinstance-attribute

decoration: BoxDecoration | None = None

The background decoration.

drawerclass-attributeinstance-attribute

drawer: NavigationDrawer | None = None

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

end_drawerclass-attributeinstance-attribute

end_drawer: NavigationDrawer | None = None

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

floating_action_buttonclass-attributeinstance-attribute

floating_action_button: FloatingActionButton | None = None

A FloatingActionButton control to display on top of Page content.

floating_action_button_locationclass-attributeinstance-attribute

floating_action_button_location: (
    FloatingActionButtonLocation | OffsetValue | None
) = None

Describes position of floating_action_button

foreground_decorationclass-attributeinstance-attribute

foreground_decoration: BoxDecoration | None = None

The foreground decoration.

fullscreen_dialogclass-attributeinstance-attribute

fullscreen_dialog: bool = False

If True, the view is a fullscreen modal dialog.

horizontal_alignmentclass-attributeinstance-attribute

horizontal_alignment: CrossAxisAlignment = (
    CrossAxisAlignment.START
)

How the child Controls should be placed horizontally.

navigation_barclass-attributeinstance-attribute

navigation_bar: (
    NavigationBar | CupertinoNavigationBar | None
) = None

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

paddingclass-attributeinstance-attribute

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

A space between page contents and its edges.

routeclass-attributeinstance-attribute

route: str = 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.

servicesclass-attributeinstance-attribute

services: list[Service] = field(
    default_factory=list, metadata={"skip": True}
)

A list of Service controls associated with this view.

spacingclass-attributeinstance-attribute

spacing: Number = 10

The vertical spacing between controls on the Page.

vertical_alignmentclass-attributeinstance-attribute

vertical_alignment: MainAxisAlignment = (
    MainAxisAlignment.START
)

Defines how the child controls should be placed vertically.

Events

on_confirm_popclass-attributeinstance-attribute

on_confirm_pop: ControlEventHandler[View] | None = None

An event handler that is called when the view is about to be popped. You can use this event to confirm or cancel the pop action by calling confirm_pop method.

Methods

close_drawerasync

close_drawer()

Close the drawer.

close_end_drawerasync

close_end_drawer()

Close the end drawer.

confirm_popasync

confirm_pop(should_pop: bool) -> None

Resolves a pending pop-confirmation request for this view.

Call this from on_confirm_pop to allow or cancel the current back-navigation attempt.

Parameters:

  • should_pop (bool) - True to proceed with popping this view, False to keep the view on the navigation stack.
Notes
  • This method only has effect while a pop confirmation is pending.
  • If not called, the frontend confirmation wait times out and the pop is canceled.

show_drawerasync

show_drawer()

Show the drawer.

Raises:

  • ValueError - If no drawer is defined.

show_end_drawerasync

show_end_drawer()

Show the end drawer.

Raises: