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
appbar- AnAppBarcontrol to display at the top of thePage.bgcolor- Background color of the view.bottom_appbar- ABottomAppBarcontrol to display at the bottom of thePage.can_pop- Whether the view can be popped.controls- A list of controls to display.decoration- The background decoration.drawer- ANavigationDrawercontrol to display as a panel sliding from the start edge of the view.end_drawer- ANavigationDrawercontrol to display as a panel sliding from the end edge of the view.floating_action_button- AFloatingActionButtoncontrol to display on top ofPagecontent.floating_action_button_location- Describes position offloating_action_buttonforeground_decoration- The foreground decoration.fullscreen_dialog- IfTrue, the view is a fullscreen modal dialog.horizontal_alignment- How the child Controls should be placed horizontally.navigation_bar- A navigation bar (NavigationBarorCupertinoNavigationBar) control to display at the bottom of thePage.padding- A space between page contents and its edges.route- View's route - not currently used by Flet framework, but can be used in a user program to updatePage.routewhen a view popped.services- A list ofServicecontrols associated with this view.spacing- The vertical spacing betweencontrolson thePage.vertical_alignment- Defines how the childcontrolsshould be placed vertically.
Events
on_confirm_pop- An event handler that is called when the view is about to be popped.
Methods
close_drawer- Close the drawer.close_end_drawer- Close the end drawer.confirm_pop- Resolves a pending pop-confirmation request for this view.show_drawer- Show the drawer.show_end_drawer- Show the end drawer.
Properties
appbarclass-attributeinstance-attribute
appbar: AppBar | CupertinoAppBar | None = NoneAn AppBar control to display at the top of the Page.
bgcolorclass-attributeinstance-attribute
bgcolor: ColorValue | None = NoneBackground color of the view.
bottom_appbarclass-attributeinstance-attribute
bottom_appbar: BottomAppBar | None = NoneA BottomAppBar control to display at the bottom of the Page.
controlsclass-attributeinstance-attribute
controls: list[BaseControl] = field(default_factory=list)A list of controls to display.
decorationclass-attributeinstance-attribute
decoration: BoxDecoration | None = NoneThe background decoration.
drawerclass-attributeinstance-attribute
drawer: NavigationDrawer | None = NoneA NavigationDrawer control to display as a panel sliding from the start edge of the view.
end_drawerclass-attributeinstance-attribute
end_drawer: NavigationDrawer | None = NoneA 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 = NoneA FloatingActionButton control to display on top of Page content.
floating_action_button_locationclass-attributeinstance-attribute
floating_action_button_location: (
FloatingActionButtonLocation | OffsetValue | None
) = NoneDescribes position of floating_action_button
foreground_decorationclass-attributeinstance-attribute
foreground_decoration: BoxDecoration | None = NoneThe foreground decoration.
fullscreen_dialogclass-attributeinstance-attribute
fullscreen_dialog: bool = FalseIf 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
) = NoneA 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 = 10The vertical spacing between controls on the Page.
Has effect only when vertical_alignment
is set to MainAxisAlignment.START,
MainAxisAlignment.END, or MainAxisAlignment.CENTER.
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 = NoneAn 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
confirm_popasync
confirm_pop(should_pop: bool) -> NoneResolves 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) -
Trueto proceed with popping this view,Falseto keep the view on the navigation stack.
- 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_end_drawerasync
show_end_drawer()Show the end drawer.
Raises:
- ValueError - If no
end_draweris defined.