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: WidgetRefThe 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
impl Scrollbar
Sourcepub fn new<K>(child: impl IntoWidget<K>) -> Scrollbar
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.
Sourcepub fn controller(self, controller: ScrollControllerRef) -> Scrollbar
pub fn controller(self, controller: ScrollControllerRef) -> Scrollbar
Dart Scrollbar(controller:).
Sourcepub fn thumb_visibility(self, thumb_visibility: bool) -> Scrollbar
pub fn thumb_visibility(self, thumb_visibility: bool) -> Scrollbar
Dart Scrollbar(thumbVisibility:).
Sourcepub fn track_visibility(self, track_visibility: bool) -> Scrollbar
pub fn track_visibility(self, track_visibility: bool) -> Scrollbar
Dart Scrollbar(trackVisibility:).
Sourcepub fn notification_predicate(
self,
notification_predicate: ScrollNotificationPredicate,
) -> Scrollbar
pub fn notification_predicate( self, notification_predicate: ScrollNotificationPredicate, ) -> Scrollbar
Dart Scrollbar(notificationPredicate:).
Sourcepub fn interactive(self, interactive: bool) -> Scrollbar
pub fn interactive(self, interactive: bool) -> Scrollbar
Dart Scrollbar(interactive:).
Sourcepub fn scrollbar_orientation(
self,
scrollbar_orientation: ScrollbarOrientation,
) -> Scrollbar
pub fn scrollbar_orientation( self, scrollbar_orientation: ScrollbarOrientation, ) -> Scrollbar
Dart Scrollbar(scrollbarOrientation:).
Trait Implementations§
Source§impl StatelessWidget for Scrollbar
impl StatelessWidget for Scrollbar
Source§fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef
fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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)
fn debug_check_constructor(&self)
Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
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 Scrollbarwhere
*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
impl UnsafeUnpin for Scrollbarwhere
*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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.