pub struct PrimaryScrollController {
pub key: Option<KeyRef>,
pub controller: Option<ScrollControllerRef>,
pub scroll_direction: Option<Axis>,
pub automatically_inherit_for_platforms: HashSet<TargetPlatform>,
pub child: WidgetRef,
}Expand description
Associates a ScrollController with a subtree.
When a ScrollView has primary set to true, the ScrollView
uses of to inherit the PrimaryScrollController associated with its
subtree.
A scroll view that doesn’t have a controller or the primary flag set will
inherit the primary scroll controller, if should_inherit allows
it. By default should_inherit is true for mobile platforms when
the scroll view has a scroll direction of Axis::Vertical. This automatic inheritance
can be configured with
automatically_inherit_for_platforms and
scroll_direction.
Inheriting this scroll controller can provide default behavior for scroll
views in a subtree. For example, the Scaffold uses this mechanism to
implement the scroll-to-top gesture on iOS.
Another default behavior handled by the PrimaryScrollController is default
crate::ScrollActions. If a scroll action is not handled by an otherwise focused
part of the application, the scroll action will be evaluated using the scroll
view associated with a PrimaryScrollController, for example, when executing
Shortcuts key events like page up and down.
See also:
crate::ScrollAction, ancrate::Actionthat scrolls theScrollablethat encloses the current primary focus or is attached to the primary scroll controller.Shortcuts, a widget that establishes aShortcutManagerto be used by its descendants when invoking ancrate::Actionvia a keyboard key combination that maps to ancrate::Intent.
Fields§
§key: Option<KeyRef>§controller: Option<ScrollControllerRef>The ScrollController associated with the subtree.
See also:
ScrollView.controller, which discusses the purpose of specifying a scroll controller.
scroll_direction: Option<Axis>The Axis this controller is configured for scroll views to
automatically inherit.
Used in conjunction with
automatically_inherit_for_platforms. If
the current TargetPlatform is not included there, this is ignored.
When None, no scroll view in any axis will automatically inherit this
controller. This is dissimilar to PrimaryScrollController::none. When a
primary scroll controller is inherited, ScrollView will insert
PrimaryScrollController::none into the tree to prevent further descendant
scroll views from inheriting the current primary scroll controller.
For the direction in which active scrolling may be occurring, see
waft_rendering::ScrollDirection.
Defaults to Axis::Vertical.
automatically_inherit_for_platforms: HashSet<TargetPlatform>The TargetPlatforms this controller is configured for scroll views to
automatically inherit.
Used in conjunction with scroll_direction. If the Axis
provided to should_inherit is not
scroll_direction, this is ignored.
When empty, no scroll view in any axis will automatically inherit this controller. Defaults to the mobile platforms.
child: WidgetRefThe widget below this widget in the tree.
Implementations§
Source§impl PrimaryScrollController
impl PrimaryScrollController
Sourcepub fn new<K>(
controller: ScrollControllerRef,
child: impl IntoWidget<K>,
) -> PrimaryScrollController
pub fn new<K>( controller: ScrollControllerRef, child: impl IntoWidget<K>, ) -> PrimaryScrollController
Creates a widget that associates a ScrollController with a subtree.
Sourcepub fn none<K>(child: impl IntoWidget<K>) -> PrimaryScrollController
pub fn none<K>(child: impl IntoWidget<K>) -> PrimaryScrollController
Creates a subtree without an associated ScrollController.
Sourcepub fn key(self, key: KeyRef) -> PrimaryScrollController
pub fn key(self, key: KeyRef) -> PrimaryScrollController
Dart PrimaryScrollController(key:).
Sourcepub fn scroll_direction(self, scroll_direction: Axis) -> PrimaryScrollController
pub fn scroll_direction(self, scroll_direction: Axis) -> PrimaryScrollController
Dart PrimaryScrollController(scrollDirection:).
Sourcepub fn automatically_inherit_for_platforms(
self,
automatically_inherit_for_platforms: HashSet<TargetPlatform>,
) -> PrimaryScrollController
pub fn automatically_inherit_for_platforms( self, automatically_inherit_for_platforms: HashSet<TargetPlatform>, ) -> PrimaryScrollController
Dart PrimaryScrollController(automaticallyInheritForPlatforms:).
Sourcepub fn should_inherit(
app: &mut App,
context: BuildContext,
scroll_direction: Axis,
) -> bool
pub fn should_inherit( app: &mut App, context: BuildContext, scroll_direction: Axis, ) -> bool
Returns true if this PrimaryScrollController is configured to be
automatically inherited for the current TargetPlatform and the given
Axis.
This method is typically not called directly. ScrollView will call this
method if it has not been provided a ScrollController and
ScrollView.primary is unset.
Sourcepub fn maybe_of(
app: &mut App,
context: BuildContext,
) -> Option<ScrollControllerRef>
pub fn maybe_of( app: &mut App, context: BuildContext, ) -> Option<ScrollControllerRef>
Returns the ScrollController most closely associated with the given
context.
Returns None if there is no ScrollController associated with the given
context.
Calling this method will create a dependency on the closest
PrimaryScrollController in the context, if there is one.
See also:
PrimaryScrollController::of, which is similar to this method, but panics if noPrimaryScrollControllerancestor is found.
Sourcepub fn of(app: &mut App, context: BuildContext) -> ScrollControllerRef
pub fn of(app: &mut App, context: BuildContext) -> ScrollControllerRef
Returns the ScrollController most closely associated with the given
context.
Calling this method will create a dependency on the closest
PrimaryScrollController in the context.
§Panics
If no PrimaryScrollController ancestor is found.
See also:
PrimaryScrollController::maybe_of, which is similar to this method, but returnsNoneif noPrimaryScrollControllerancestor is found.
Trait Implementations§
Source§impl Debug for PrimaryScrollController
impl Debug for PrimaryScrollController
Source§impl InheritedWidget for PrimaryScrollController
impl InheritedWidget for PrimaryScrollController
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 update_should_notify(&self, old_widget: &PrimaryScrollController) -> bool
fn update_should_notify(&self, old_widget: &PrimaryScrollController) -> bool
Source§fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>
fn as_inherited_theme(&self) -> Option<&dyn InheritedTheme>
this is InheritedTheme: an inherited widget that is an InheritedTheme
answers with itself, which is what InheritedTheme::capture collects.Auto Trait Implementations§
impl !RefUnwindSafe for PrimaryScrollController
impl !Send for PrimaryScrollController
impl !Sync for PrimaryScrollController
impl !UnwindSafe for PrimaryScrollController
impl Forget for PrimaryScrollController
impl Freeze for PrimaryScrollControllerwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
NonZero<u32>: Freeze,
&'static ScrollControllerVTable: Freeze,
*const RcInner<Keep> is !null: Freeze,
PhantomData<RcInner<Keep>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<(TargetPlatform, ())>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
impl Move for PrimaryScrollController
impl Unpin for PrimaryScrollController
impl UnsafeUnpin for PrimaryScrollControllerwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
&'static ScrollControllerVTable: UnsafeUnpin,
*const RcInner<Keep> is !null: UnsafeUnpin,
PhantomData<RcInner<Keep>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(TargetPlatform, ())>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: 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<InheritedKind> for Wwhere
W: InheritedWidget,
impl<W> IntoWidget<InheritedKind> for Wwhere
W: InheritedWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.