Skip to main content

SliverAppBar

Struct SliverAppBar 

Source
pub struct SliverAppBar {
Show 39 fields pub key: Option<KeyRef>, pub leading: Option<WidgetRef>, pub automatically_imply_leading: bool, pub title: Option<WidgetRef>, pub actions: Option<Vec<WidgetRef>>, pub automatically_imply_actions: bool, pub flexible_space: Option<WidgetRef>, pub bottom: Option<PreferredSizeWidgetRef>, pub elevation: Option<f64>, pub scrolled_under_elevation: Option<f64>, pub shadow_color: Option<Color>, pub surface_tint_color: Option<Color>, pub force_elevated: bool, pub background_color: Option<AnyColor>, pub foreground_color: Option<Color>, pub icon_theme: Option<IconThemeData>, pub actions_icon_theme: Option<IconThemeData>, pub primary: bool, pub center_title: Option<bool>, pub exclude_header_semantics: bool, pub title_spacing: Option<f64>, pub collapsed_height: Option<f64>, pub expanded_height: Option<f64>, pub floating: bool, pub pinned: bool, pub shape: Option<ShapeBorderRef>, pub snap: bool, pub stretch: bool, pub stretch_trigger_offset: f64, pub on_stretch_trigger: Option<AsyncCallback>, pub toolbar_height: f64, pub leading_width: Option<f64>, pub toolbar_text_style: Option<TextStyle>, pub title_text_style: Option<TextStyle>, pub system_overlay_style: Option<SystemUiOverlayStyle>, pub force_material_transparency: bool, pub use_default_semantics_order: bool, pub clip_behavior: Option<Clip>, pub actions_padding: Option<EdgeInsetsGeometry>, /* private fields */
}
Expand description

A Material Design app bar that integrates with a CustomScrollView.

An app bar consists of a toolbar and potentially other widgets, such as a TabBar and a FlexibleSpaceBar. App bars typically expose one or more common actions with IconButtons which are optionally followed by a PopupMenuButton for less common operations.

Sliver app bars are typically used as the first child of a CustomScrollView, which lets the app bar integrate with the scroll view so that it can vary in height according to the scroll offset or float above the other content in the scroll view. For a fixed-height app bar at the top of the screen see AppBar, which is used in the Scaffold::app_bar slot.

The AppBar displays the toolbar widgets, leading, title, and actions, above the bottom (if any). If a flexible_space widget is specified then it is stacked behind the toolbar and the bottom widget.

The property snap can only be set to true if floating is also true.

See also:

Fields§

§key: Option<KeyRef>§leading: Option<WidgetRef>

See AppBar::leading.

This property is used to configure an AppBar.

§automatically_imply_leading: bool

See AppBar::automatically_imply_leading.

This property is used to configure an AppBar.

§title: Option<WidgetRef>

See AppBar::title.

This property is used to configure an AppBar.

§actions: Option<Vec<WidgetRef>>

See AppBar::actions.

This property is used to configure an AppBar.

§automatically_imply_actions: bool

See AppBar::automatically_imply_actions.

This property is used to configure an AppBar.

§flexible_space: Option<WidgetRef>

See AppBar::flexible_space.

This property is used to configure an AppBar.

§bottom: Option<PreferredSizeWidgetRef>

See AppBar::bottom.

This property is used to configure an AppBar.

§elevation: Option<f64>

See AppBar::elevation.

This property is used to configure an AppBar.

§scrolled_under_elevation: Option<f64>

See AppBar::scrolled_under_elevation.

This property is used to configure an AppBar.

§shadow_color: Option<Color>

See AppBar::shadow_color.

This property is used to configure an AppBar.

§surface_tint_color: Option<Color>

See AppBar::surface_tint_color.

This property is used to configure an AppBar.

§force_elevated: bool

Whether to show the shadow appropriate for the elevation even if the content is not scrolled under the AppBar.

Defaults to false, meaning that the elevation is only applied when the AppBar is being displayed over content that is scrolled under it.

When set to true, the elevation is applied regardless.

Ignored when elevation is zero.

§background_color: Option<AnyColor>

See AppBar::background_color.

This property is used to configure an AppBar.

§foreground_color: Option<Color>

See AppBar::foreground_color.

This property is used to configure an AppBar.

§icon_theme: Option<IconThemeData>

See AppBar::icon_theme.

This property is used to configure an AppBar.

§actions_icon_theme: Option<IconThemeData>

See AppBar::actions_icon_theme.

This property is used to configure an AppBar.

§primary: bool

See AppBar::primary.

This property is used to configure an AppBar.

§center_title: Option<bool>

See AppBar::center_title.

This property is used to configure an AppBar.

§exclude_header_semantics: bool

See AppBar::exclude_header_semantics.

This property is used to configure an AppBar.

§title_spacing: Option<f64>

See AppBar::title_spacing.

This property is used to configure an AppBar.

§collapsed_height: Option<f64>

Defines the height of the app bar when it is collapsed.

By default, the collapsed height is toolbar_height. If bottom widget is specified, then its height from PreferredSizeWidget::preferred_size is added to the height. If primary is true, then the MediaQuery top padding, EdgeInsets::top of MediaQueryData::padding, is added as well.

If pinned and floating are true, with bottom set, the default collapsed height is only the height of PreferredSizeWidget::preferred_size with the MediaQuery top padding.

§expanded_height: Option<f64>

The size of the app bar when it is fully expanded.

By default, the total height of the toolbar and the bottom widget (if any). If a flexible_space widget is specified this height should be big enough to accommodate whatever that widget contains.

This does not include the status bar height (which will be automatically included if primary is true).

§floating: bool

Whether the app bar should become visible as soon as the user scrolls towards the app bar.

Otherwise, the user will need to scroll near the top of the scroll view to reveal the app bar.

If snap is true then a scroll that exposes the app bar will trigger an animation that slides the entire app bar into view. Similarly if a scroll dismisses the app bar, the animation will slide it completely out of view.

§pinned: bool

Whether the app bar should remain visible at the start of the scroll view.

The app bar can still expand and contract as the user scrolls, but it will remain visible rather than being scrolled out of view.

§shape: Option<ShapeBorderRef>

See AppBar::shape.

This property is used to configure an AppBar.

§snap: bool

If snap and floating are true then the floating app bar will “snap” into view.

If snap is true then a scroll that exposes the floating app bar will trigger an animation that slides the entire app bar into view. Similarly if a scroll dismisses the app bar, the animation will slide the app bar completely out of view. Additionally, setting snap to true will fully expand the floating app bar when the framework tries to reveal the contents of the app bar by calling RenderObject::show_on_screen. For example, when a TextField in the floating app bar gains focus, if snap is true, the framework will always fully expand the floating app bar, in order to reveal the focused TextField.

Snapping only applies when the app bar is floating, not when the app bar appears at the top of its scroll view.

§stretch: bool

Whether the app bar should stretch to fill the over-scroll area.

The app bar can still expand and contract as the user scrolls, but it will also stretch when the user over-scrolls.

§stretch_trigger_offset: f64

The offset of overscroll required to activate on_stretch_trigger.

This defaults to 100.0.

§on_stretch_trigger: Option<AsyncCallback>

The callback function to be executed when a user over-scrolls to the offset specified by stretch_trigger_offset.

§toolbar_height: f64

See AppBar::toolbar_height.

This property is used to configure an AppBar.

§leading_width: Option<f64>

See AppBar::leading_width.

This property is used to configure an AppBar.

§toolbar_text_style: Option<TextStyle>

See AppBar::toolbar_text_style.

This property is used to configure an AppBar.

§title_text_style: Option<TextStyle>

See AppBar::title_text_style.

This property is used to configure an AppBar.

§system_overlay_style: Option<SystemUiOverlayStyle>

See AppBar::system_overlay_style.

This property is used to configure an AppBar.

§force_material_transparency: bool

See AppBar::force_material_transparency.

This property is used to configure an AppBar.

§use_default_semantics_order: bool

See AppBar::use_default_semantics_order.

This property is used to configure an AppBar.

§clip_behavior: Option<Clip>

The content will be clipped (or not) according to this option.

§actions_padding: Option<EdgeInsetsGeometry>

See AppBar::actions_padding.

This property is used to configure an AppBar.

Implementations§

Source§

impl SliverAppBar

Source

pub fn new() -> SliverAppBar

Creates a Material Design app bar that can be placed in a CustomScrollView.

Source

pub fn medium() -> SliverAppBar

Creates a Material Design medium top app bar that can be placed in a CustomScrollView.

Returns a SliverAppBar configured with appropriate defaults for a medium top app bar as defined in Material 3. It starts fully expanded with the title in an area underneath the main row of icons. When the CustomScrollView is scrolled, the title will be scrolled under the main row. When it is fully collapsed, a smaller version of the title will fade in on the main row. The reverse will happen if it is expanded again.

See also:

Source

pub fn large() -> SliverAppBar

Creates a Material Design large top app bar that can be placed in a CustomScrollView.

Returns a SliverAppBar configured with appropriate defaults for a large top app bar as defined in Material 3. It starts fully expanded with the title in an area underneath the main row of icons. When the CustomScrollView is scrolled, the title will be scrolled under the main row. When it is fully collapsed, a smaller version of the title will fade in on the main row. The reverse will happen if it is expanded again.

See also:

Source

pub fn key(self, key: KeyRef) -> SliverAppBar

Dart SliverAppBar(key:).

Source

pub fn leading<K>(self, leading: impl IntoWidget<K>) -> SliverAppBar

Dart SliverAppBar(leading:).

Source

pub fn automatically_imply_leading( self, automatically_imply_leading: bool, ) -> SliverAppBar

Dart SliverAppBar(automaticallyImplyLeading:).

Source

pub fn title<K>(self, title: impl IntoWidget<K>) -> SliverAppBar

Dart SliverAppBar(title:).

Source

pub fn actions(self, actions: Vec<WidgetRef>) -> SliverAppBar

Dart SliverAppBar(actions:).

Source

pub fn automatically_imply_actions( self, automatically_imply_actions: bool, ) -> SliverAppBar

Dart SliverAppBar(automaticallyImplyActions:).

Source

pub fn flexible_space<K>( self, flexible_space: impl IntoWidget<K>, ) -> SliverAppBar

Dart SliverAppBar(flexibleSpace:).

Source

pub fn bottom(self, bottom: PreferredSizeWidgetRef) -> SliverAppBar

Dart SliverAppBar(bottom:).

Source

pub fn elevation(self, elevation: f64) -> SliverAppBar

Dart SliverAppBar(elevation:).

Source

pub fn scrolled_under_elevation( self, scrolled_under_elevation: f64, ) -> SliverAppBar

Dart SliverAppBar(scrolledUnderElevation:).

Source

pub fn shadow_color(self, shadow_color: Color) -> SliverAppBar

Dart SliverAppBar(shadowColor:).

Source

pub fn surface_tint_color(self, surface_tint_color: Color) -> SliverAppBar

Dart SliverAppBar(surfaceTintColor:).

Source

pub fn force_elevated(self, force_elevated: bool) -> SliverAppBar

Dart SliverAppBar(forceElevated:).

Source

pub fn background_color( self, background_color: impl Into<AnyColor>, ) -> SliverAppBar

Dart SliverAppBar(backgroundColor:).

Source

pub fn foreground_color(self, foreground_color: Color) -> SliverAppBar

Dart SliverAppBar(foregroundColor:).

Source

pub fn icon_theme(self, icon_theme: IconThemeData) -> SliverAppBar

Dart SliverAppBar(iconTheme:).

Source

pub fn actions_icon_theme( self, actions_icon_theme: IconThemeData, ) -> SliverAppBar

Dart SliverAppBar(actionsIconTheme:).

Source

pub fn primary(self, primary: bool) -> SliverAppBar

Dart SliverAppBar(primary:).

Source

pub fn center_title(self, center_title: bool) -> SliverAppBar

Dart SliverAppBar(centerTitle:).

Source

pub fn exclude_header_semantics( self, exclude_header_semantics: bool, ) -> SliverAppBar

Dart SliverAppBar(excludeHeaderSemantics:).

Source

pub fn title_spacing(self, title_spacing: f64) -> SliverAppBar

Dart SliverAppBar(titleSpacing:).

Source

pub fn collapsed_height(self, collapsed_height: f64) -> SliverAppBar

Dart SliverAppBar(collapsedHeight:).

Source

pub fn expanded_height(self, expanded_height: f64) -> SliverAppBar

Dart SliverAppBar(expandedHeight:).

Source

pub fn floating(self, floating: bool) -> SliverAppBar

Dart SliverAppBar(floating:).

Source

pub fn pinned(self, pinned: bool) -> SliverAppBar

Dart SliverAppBar(pinned:).

Source

pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> SliverAppBar

Dart SliverAppBar(shape:).

Source

pub fn snap(self, snap: bool) -> SliverAppBar

Dart SliverAppBar(snap:).

Source

pub fn stretch(self, stretch: bool) -> SliverAppBar

Dart SliverAppBar(stretch:).

Source

pub fn stretch_trigger_offset(self, stretch_trigger_offset: f64) -> SliverAppBar

Dart SliverAppBar(stretchTriggerOffset:).

Source

pub fn on_stretch_trigger( self, on_stretch_trigger: AsyncCallback, ) -> SliverAppBar

Dart SliverAppBar(onStretchTrigger:).

Source

pub fn toolbar_height(self, toolbar_height: f64) -> SliverAppBar

Dart SliverAppBar(toolbarHeight:).

Source

pub fn leading_width(self, leading_width: f64) -> SliverAppBar

Dart SliverAppBar(leadingWidth:).

Source

pub fn toolbar_text_style(self, toolbar_text_style: TextStyle) -> SliverAppBar

Dart SliverAppBar(toolbarTextStyle:).

Source

pub fn title_text_style(self, title_text_style: TextStyle) -> SliverAppBar

Dart SliverAppBar(titleTextStyle:).

Source

pub fn system_overlay_style( self, system_overlay_style: SystemUiOverlayStyle, ) -> SliverAppBar

Dart SliverAppBar(systemOverlayStyle:).

Source

pub fn force_material_transparency( self, force_material_transparency: bool, ) -> SliverAppBar

Dart SliverAppBar(forceMaterialTransparency:).

Source

pub fn use_default_semantics_order( self, use_default_semantics_order: bool, ) -> SliverAppBar

Dart SliverAppBar(useDefaultSemanticsOrder:).

Source

pub fn clip_behavior(self, clip_behavior: Clip) -> SliverAppBar

Dart SliverAppBar(clipBehavior:).

Source

pub fn actions_padding( self, actions_padding: impl Into<EdgeInsetsGeometry>, ) -> SliverAppBar

Dart SliverAppBar(actionsPadding:).

Trait Implementations§

Source§

impl Debug for SliverAppBar

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SliverAppBar

Source§

fn default() -> SliverAppBar

Returns the “default value” for a type. Read more
Source§

impl StatefulWidget for SliverAppBar

Source§

type State = SliverAppBarState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn debug_check_constructor(&self)

Source§

fn create_state(&self) -> SliverAppBarState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties: the properties a dump shows for this widget, in Dart’s order. Dart’s Widget base only sets the dense tree style, which the framework does.
Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Source§

fn type_name(&self) -> &'static str

See Widget::type_name. A stateful form another widget kind becomes (an animated or status transition widget) names the widget it wraps.

Auto Trait Implementations§

§

impl !RefUnwindSafe for SliverAppBar

§

impl !Send for SliverAppBar

§

impl !Sync for SliverAppBar

§

impl !UnwindSafe for SliverAppBar

§

impl Forget for SliverAppBar

§

impl Freeze for SliverAppBar
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const u8 is !null: Freeze, PhantomData<Rc<dyn Widget>>: Freeze, &'static dyn ColorExtension: Freeze, *const RcInner<dyn ColorExtension> is !null: Freeze, PhantomData<RcInner<dyn ColorExtension>>: Freeze, PhantomData<Shadow>: Freeze, *const RcInner<dyn Fn(&IconThemeData, &mut App, AnyElement) -> IconThemeData> is !null: Freeze, PhantomData<RcInner<dyn Fn(&IconThemeData, &mut App, AnyElement) -> IconThemeData>>: Freeze, *const RcInner<dyn ShapeBorder> is !null: Freeze, PhantomData<RcInner<dyn ShapeBorder>>: Freeze, *const RcInner<dyn Fn(&mut App) -> Task<()>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App) -> Task<()>>>: Freeze, PhantomData<u8>: Freeze, PhantomData<String>: Freeze, *const RcInner<Paint> is !null: Freeze, PhantomData<RcInner<Paint>>: Freeze, PhantomData<FontFeature>: Freeze, PhantomData<FontVariation>: Freeze,

§

impl Move for SliverAppBar

§

impl Unpin for SliverAppBar
where Rc<dyn Key>: Unpin, Rc<dyn Widget>: Unpin, *const u8 is !null: Unpin, &'static dyn ColorExtension: Unpin, Rc<dyn ColorExtension>: Unpin, Rc<dyn Fn(&IconThemeData, &mut App, AnyElement) -> IconThemeData>: Unpin, Rc<dyn ShapeBorder>: Unpin, Rc<dyn Fn(&mut App) -> Task<()>>: Unpin, Rc<Paint>: Unpin,

§

impl UnsafeUnpin for SliverAppBar

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>