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- An AppBar control to display at the top of thePage.bgcolor- Background color of the view.bottom_appbar- A BottomAppBar control 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- A NavigationDrawer control to display as a panel sliding from the start edge of the view.end_drawer- A NavigationDrawer control to display as a panel sliding from the end edge of the view.floating_action_button- A FloatingActionButton control to display on top ofPagecontent.floating_action_button_location- Describes position of floating_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 (NavigationBar or CupertinoNavigationBar) 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 update flet.Page.route when a view popped.services- A list of Service controls associated with this view.spacing- The vertical spacing between controls on thePage.vertical_alignment- Defines how the child controls should 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: Optional[Union[AppBar, CupertinoAppBar]] = NoneAn AppBar control to display at the top of the Page.
bgcolorclass-attributeinstance-attribute
bgcolor: Optional[ColorValue] = NoneBackground color of the view.
bottom_appbarclass-attributeinstance-attribute
bottom_appbar: Optional[BottomAppBar] = 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: Optional[BoxDecoration] = NoneThe background decoration.
drawerclass-attributeinstance-attribute
drawer: Optional[NavigationDrawer] = NoneA NavigationDrawer control to display as a panel sliding from the start edge of the view.
end_drawerclass-attributeinstance-attribute
end_drawer: Optional[NavigationDrawer] = NoneA NavigationDrawer control to display as a panel sliding from the end edge of the view.
floating_action_buttonclass-attributeinstance-attribute
floating_action_button: Optional[FloatingActionButton] = NoneA FloatingActionButton control to display on top of Page content.
floating_action_button_locationclass-attributeinstance-attribute
floating_action_button_location: Optional[Union[FloatingActionButtonLocation, OffsetValue]] = NoneDescribes position of floating_action_button
foreground_decorationclass-attributeinstance-attribute
foreground_decoration: Optional[BoxDecoration] = 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.STARTHow the child Controls should be placed horizontally.
navigation_barclass-attributeinstance-attribute
navigation_bar: Union[NavigationBar, CupertinoNavigationBar, None] = NoneA navigation bar (NavigationBar or CupertinoNavigationBar) control to display at the bottom of the Page.
paddingclass-attributeinstance-attribute
padding: Optional[PaddingValue] = 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 flet.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 flet.MainAxisAlignment.START, flet.MainAxisAlignment.END, or flet.MainAxisAlignment.CENTER.
vertical_alignmentclass-attributeinstance-attribute
vertical_alignment: MainAxisAlignment = MainAxisAlignment.STARTDefines how the child controls should be placed vertically.
Events
on_confirm_popclass-attributeinstance-attribute
on_confirm_pop: Optional[ControlEventHandler[View]] = 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)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) -
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_drawer is defined.