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
Properties
aligndeprecated - Has no effect.animate_aligndeprecated - Has no effect.animate_margindeprecated - Has no effect.animate_offsetdeprecated - Has no effect.animate_opacitydeprecated - Has no effect.animate_positiondeprecated - Has no effect.animate_rotationdeprecated - Has no effect.animate_scaledeprecated - Has no effect.animate_sizedeprecated - Has no effect.appbar- AnAppBarcontrol to display at the top of thePage.aspect_ratiodeprecated - Has no effect.bgcolor- Background color of the view.bottomdeprecated - Has no effect.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.flipdeprecated - Has no effect.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.heightdeprecated - Has no effect.horizontal_alignment- How the child Controls should be placed horizontally.leftdeprecated - Has no effect.margindeprecated - Has no effect.max_heightdeprecated - Has no effect.max_widthdeprecated - Has no effect.min_heightdeprecated - Has no effect.min_widthdeprecated - Has no effect.navigation_bar- A navigation bar (NavigationBarorCupertinoNavigationBar) control to display at the bottom of thePage.offsetdeprecated - Has no effect.padding- A space between page contents and its edges.rightdeprecated - Has no effect.rotatedeprecated - Has no effect.route- View's route - not currently used by Flet framework, but can be used in a user program to updatePage.routewhen a view popped.scaledeprecated - Has no effect.services- A list ofServicecontrols associated with this view.size_change_interval- Sampling interval in milliseconds foron_size_changeevent.spacing- The vertical spacing betweencontrolson thePage.topdeprecated - Has no effect.transformdeprecated - Has no effect.vertical_alignment- Defines how the childcontrolsshould be placed vertically.widthdeprecated - Has no effect.
Events
on_animation_enddeprecated - Has no effect.on_confirm_pop- An event handler that is called when the view is about to be popped.on_size_change- Called when the size of this view's body changes.
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
alignclass-attributedeprecatedinstance-attribute
align: Alignment | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
animate_alignclass-attributedeprecatedinstance-attribute
animate_align: AnimationValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
animate_marginclass-attributedeprecatedinstance-attribute
animate_margin: AnimationValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
animate_offsetclass-attributedeprecatedinstance-attribute
animate_offset: AnimationValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
animate_opacityclass-attributedeprecatedinstance-attribute
animate_opacity: AnimationValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
animate_positionclass-attributedeprecatedinstance-attribute
animate_position: AnimationValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
animate_rotationclass-attributedeprecatedinstance-attribute
animate_rotation: AnimationValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
animate_scaleclass-attributedeprecatedinstance-attribute
animate_scale: AnimationValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
animate_sizeclass-attributedeprecatedinstance-attribute
animate_size: AnimationValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
appbarclass-attributeinstance-attribute
appbar: AppBar | CupertinoAppBar | None = NoneAn AppBar control to display at the top of the Page.
aspect_ratioclass-attributedeprecatedinstance-attribute
aspect_ratio: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
bgcolorclass-attributeinstance-attribute
bgcolor: ColorValue | None = NoneBackground color of the view.
bottomclass-attributedeprecatedinstance-attribute
bottom: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
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.
flipclass-attributedeprecatedinstance-attribute
flip: Flip | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
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.
heightclass-attributedeprecatedinstance-attribute
height: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
horizontal_alignmentclass-attributeinstance-attribute
horizontal_alignment: CrossAxisAlignment = (
CrossAxisAlignment.START
)How the child Controls should be placed horizontally.
leftclass-attributedeprecatedinstance-attribute
left: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
marginclass-attributedeprecatedinstance-attribute
margin: MarginValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
max_heightclass-attributedeprecatedinstance-attribute
max_height: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
max_widthclass-attributedeprecatedinstance-attribute
max_width: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
min_heightclass-attributedeprecatedinstance-attribute
min_height: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
min_widthclass-attributedeprecatedinstance-attribute
min_width: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
navigation_barclass-attributeinstance-attribute
navigation_bar: (
NavigationBar | CupertinoNavigationBar | None
) = NoneA navigation bar (NavigationBar or CupertinoNavigationBar) control to display at the bottom of the Page.
offsetclass-attributedeprecatedinstance-attribute
offset: OffsetValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
paddingclass-attributeinstance-attribute
padding: PaddingValue | None = field(
default_factory=lambda: Padding.all(10)
)A space between page contents and its edges.
rightclass-attributedeprecatedinstance-attribute
right: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
rotateclass-attributedeprecatedinstance-attribute
rotate: RotateValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
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.
scaleclass-attributedeprecatedinstance-attribute
scale: ScaleValue | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
servicesclass-attributeinstance-attribute
services: list[Service] = field(
default_factory=list, metadata={"skip": True}
)A list of Service controls associated with this view.
size_change_intervalclass-attributeinstance-attribute
size_change_interval: int = 10Sampling interval in milliseconds for on_size_change event.
Setting to 0 calls on_size_change immediately on every change.
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.
topclass-attributedeprecatedinstance-attribute
top: Number | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
transformclass-attributedeprecatedinstance-attribute
transform: Transform | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
vertical_alignmentclass-attributeinstance-attribute
vertical_alignment: MainAxisAlignment = (
MainAxisAlignment.START
)Defines how the child controls should be placed vertically.
Events
on_animation_endclass-attributedeprecatedinstance-attribute
on_animation_end: ControlEventHandler[View] | None = NoneDeprecated since version 1.2.0 and scheduled for removal in 1.5.0. A View always fills its page, so this property has no effect.
Has no effect.
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.
on_size_changeclass-attributeinstance-attribute
on_size_change: (
EventHandler[LayoutSizeChangeEvent[View]] | None
) = NoneCalled when the size of this view's body changes.
The body is the area between the app bar and the bottom navigation bar or
bottom app bar, including padding. It shrinks while the on-screen
keyboard is shown. For the size of the whole window, use
Page.on_resize.
size_change_interval defines how often this event is called.
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.