Skip to main content

Scrollbar

Struct Scrollbar 

Source
pub struct Scrollbar {
    pub key: Option<KeyRef>,
    pub child: WidgetRef,
    pub controller: Option<ScrollControllerRef>,
    pub thumb_visibility: Option<bool>,
    pub track_visibility: Option<bool>,
    pub thickness: Option<f64>,
    pub radius: Option<Radius>,
    pub interactive: Option<bool>,
    pub notification_predicate: Option<ScrollNotificationPredicate>,
    pub scrollbar_orientation: Option<ScrollbarOrientation>,
}
Expand description

A Material Design scrollbar.

To add a scrollbar to a ScrollView, wrap the scroll view widget in a Scrollbar widget.

For more information, see RawScrollbar.

Dynamically changes to a CupertinoScrollbar, an iOS style scrollbar, by default on the iOS platform.

The color of the Scrollbar thumb will change when WidgetState::Dragged, or WidgetState::Hovered on desktop and web platforms. These stateful color choices can be changed using ScrollbarThemeData::thumb_color.

When thumb_visibility is true, the scrollbar thumb will remain visible without the fade animation. This requires that a ScrollController is provided to controller, or that the PrimaryScrollController is available.

When a ScrollView::scroll_direction is Axis::Horizontal, it is recommended that the Scrollbar is always visible, since scrolling in the horizontal axis is less discoverable.

A scrollbar track can be added using track_visibility. This can also be drawn when triggered by a hover event, or based on any WidgetState by using ScrollbarThemeData::track_visibility.

The thickness of the track and scrollbar thumb can be changed dynamically in response to WidgetStates using ScrollbarThemeData::thickness.

See also:

  • RawScrollbar, a basic scrollbar that fades in and out, extended by this class to add more animations and behaviors.
  • ScrollbarTheme, which configures the Scrollbar’s appearance.
  • CupertinoScrollbar, an iOS style scrollbar.
  • ListView, which displays a linear, scrollable list of children.
  • GridView, which displays a 2 dimensional, scrollable array of children.

Fields§

§key: Option<KeyRef>§child: WidgetRef

The widget below this widget in the tree.

The scrollbar will be stacked on top of this child. This child (and its subtree) should include a source of ScrollNotification notifications.

§controller: Option<ScrollControllerRef>

The ScrollController used to implement Scrollbar dragging.

For more information, see RawScrollbarData::controller.

§thumb_visibility: Option<bool>

Indicates that the scrollbar thumb should be visible, even when a scroll is not underway.

For more information, see RawScrollbarData::thumb_visibility.

If this property is None, then ScrollbarThemeData::thumb_visibility of ThemeData::scrollbar_theme is used. If that is also None, the default value is false.

If the thumb visibility is related to the scrollbar’s material state, use the global ScrollbarThemeData::thumb_visibility or override the sub-tree’s theme data.

§track_visibility: Option<bool>

Indicates that the scrollbar track should be visible.

When true, the scrollbar track will always be visible so long as the thumb is visible. If the scrollbar thumb is not visible, the track will not be visible either.

If this property is None, then ScrollbarThemeData::track_visibility of ThemeData::scrollbar_theme is used. If that is also None, the default value is false.

If the track visibility is related to the scrollbar’s material state, use the global ScrollbarThemeData::track_visibility or override the sub-tree’s theme data.

§thickness: Option<f64>

The thickness of the scrollbar in the cross axis of the scrollable.

If None, the default value is platform dependent. On TargetPlatform::Android, the default thickness is 4.0 pixels. On TargetPlatform::IOS, CupertinoScrollbar::DEFAULT_THICKNESS is used. The remaining platforms have a default thickness of 8.0 pixels.

§radius: Option<Radius>

The Radius of the scrollbar thumb’s rounded rectangle corners.

If None, the default value is platform dependent. On TargetPlatform::Android, no radius is applied to the scrollbar thumb. On TargetPlatform::IOS, CupertinoScrollbar::DEFAULT_RADIUS is used. The remaining platforms have a default Radius::circular of 8.0 pixels.

§interactive: Option<bool>

Whether the scrollbar should be interactive and respond to dragging on the thumb, or tapping in the track area.

Does not apply to the CupertinoScrollbar, which is always interactive to match native behavior. On Android, the scrollbar is not interactive by default.

When false, the scrollbar will not respond to gesture or hover events, and will allow to click through it.

Defaults to true when None, unless on Android, which will default to false when None.

§notification_predicate: Option<ScrollNotificationPredicate>

A check that specifies whether a ScrollNotification should be handled by this widget.

By default, checks whether notification.depth() == 0. That means if the scrollbar is wrapped around multiple scroll views, it only responds to the nearest one and shows the corresponding scrollbar thumb.

§scrollbar_orientation: Option<ScrollbarOrientation>

Dictates the orientation of the scrollbar.

ScrollbarOrientation::Top places the scrollbar on top of the screen. ScrollbarOrientation::Bottom places the scrollbar on the bottom of the screen. ScrollbarOrientation::Left places the scrollbar on the left of the screen. ScrollbarOrientation::Right places the scrollbar on the right of the screen.

ScrollbarOrientation::Top and ScrollbarOrientation::Bottom can only be used with a vertical scroll. ScrollbarOrientation::Left and ScrollbarOrientation::Right can only be used with a horizontal scroll.

For a vertical scroll the orientation defaults to ScrollbarOrientation::Right for TextDirection::Ltr and ScrollbarOrientation::Left for TextDirection::Rtl. For a horizontal scroll the orientation defaults to ScrollbarOrientation::Bottom.

Implementations§

Source§

impl Scrollbar

Source

pub fn new<K>(child: impl IntoWidget<K>) -> Scrollbar

Creates a Material Design scrollbar that by default will connect to the closest Scrollable descendant of child.

The child should be a source of ScrollNotification notifications, typically a Scrollable widget.

If the controller is None, the default behavior is to enable scrollbar dragging using the PrimaryScrollController.

When None, thickness defaults to 8.0 pixels on desktop and web, and 4.0 pixels when on mobile platforms. A None radius will result in a default of an 8.0 pixel circular radius about the corners of the scrollbar thumb, except for when executing on TargetPlatform::Android, which will render the thumb without a radius.

Source

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

Dart Scrollbar(key:).

Source

pub fn controller(self, controller: ScrollControllerRef) -> Scrollbar

Dart Scrollbar(controller:).

Source

pub fn thumb_visibility(self, thumb_visibility: bool) -> Scrollbar

Dart Scrollbar(thumbVisibility:).

Source

pub fn track_visibility(self, track_visibility: bool) -> Scrollbar

Dart Scrollbar(trackVisibility:).

Source

pub fn thickness(self, thickness: f64) -> Scrollbar

Dart Scrollbar(thickness:).

Source

pub fn radius(self, radius: Radius) -> Scrollbar

Dart Scrollbar(radius:).

Source

pub fn notification_predicate( self, notification_predicate: ScrollNotificationPredicate, ) -> Scrollbar

Dart Scrollbar(notificationPredicate:).

Source

pub fn interactive(self, interactive: bool) -> Scrollbar

Dart Scrollbar(interactive:).

Source

pub fn scrollbar_orientation( self, scrollbar_orientation: ScrollbarOrientation, ) -> Scrollbar

Dart Scrollbar(scrollbarOrientation:).

Trait Implementations§

Source§

impl Debug for Scrollbar

Source§

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

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

impl StatelessWidget for Scrollbar

Source§

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

Source§

fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef

Describes the part of the user interface represented by this widget. 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 debug_check_constructor(&self)

Dart’s constructor asserts that relate two or more arguments. Read more
Source§

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

Dart’s this is PreferredSizeWidget: a widget that implements PreferredSizeWidget answers with itself, which is what a parent asking an erased child for its preferred size reads.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Scrollbar

§

impl !Send for Scrollbar

§

impl !Sync for Scrollbar

§

impl !UnwindSafe for Scrollbar

§

impl Forget for Scrollbar

§

impl Freeze for Scrollbar
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, NonZero<u32>: Freeze, &'static ScrollControllerVTable: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool>>: Freeze,

§

impl Move for Scrollbar

§

impl Unpin for Scrollbar
where Rc<dyn Key>: Unpin, Rc<dyn Widget>: Unpin, NonZero<u32>: Unpin, &'static ScrollControllerVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool>: Unpin,

§

impl UnsafeUnpin for Scrollbar
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, &'static ScrollControllerVTable: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool>>: UnsafeUnpin,

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<StatelessKind> for W
where W: StatelessWidget,

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>