Skip to main content

SingleChildScrollView

Struct SingleChildScrollView 

Source
pub struct SingleChildScrollView {
Show 13 fields pub key: Option<KeyRef>, pub scroll_direction: Axis, pub reverse: bool, pub padding: Option<EdgeInsetsGeometry>, pub controller: Option<ScrollControllerRef>, pub primary: Option<bool>, pub physics: Option<ScrollPhysicsRef>, pub child: Option<WidgetRef>, pub drag_start_behavior: DragStartBehavior, pub clip_behavior: Clip, pub hit_test_behavior: HitTestBehavior, pub restoration_id: Option<String>, pub keyboard_dismiss_behavior: Option<ScrollViewKeyboardDismissBehavior>,
}
Expand description

A box in which a single widget can be scrolled.

This widget is useful when you have a single box that will normally be entirely visible, for example a clock face in a time picker, but you need to make sure it can be scrolled if the container gets too small in one axis (the scroll direction).

It is also useful if you need to shrink-wrap in both axes (the main scrolling direction as well as the cross axis), as one might see in a dialog or pop-up menu. In that case, you might pair the SingleChildScrollView with a ListBody child.

When you have a list of children and do not require cross-axis shrink-wrapping behavior, for example a scrolling list that is always the width of the screen, consider ListView, which is vastly more efficient than a SingleChildScrollView containing a ListBody or Column with many children.

See also:

  • ListView, which handles multiple children in a scrolling list.
  • Scrollable, which handles arbitrary scrolling effects.

Fields§

§key: Option<KeyRef>§scroll_direction: Axis

The Axis along which the scroll view’s offset increases.

Defaults to Axis::Vertical.

§reverse: bool

Whether the scroll view scrolls in the reading direction.

For example, if the reading direction is left-to-right and scroll_direction is Axis::Horizontal, then the scroll view scrolls from left to right when reverse is false and from right to left when it is true.

Defaults to false.

§padding: Option<EdgeInsetsGeometry>

The amount of space by which to inset the child.

§controller: Option<ScrollControllerRef>

An object that can be used to control the position to which this scroll view is scrolled.

Must be None if primary is true.

§primary: Option<bool>

Whether this is the primary scroll view associated with the parent PrimaryScrollController.

§physics: Option<ScrollPhysicsRef>

How the scroll view should respond to user input.

For example, determines how the scroll view continues to animate after the user stops dragging the scroll view.

Defaults to matching platform conventions.

§child: Option<WidgetRef>

The widget that scrolls.

§drag_start_behavior: DragStartBehavior

Determines the way that drag start behavior is handled.

§clip_behavior: Clip

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

Defaults to Clip::HardEdge.

§hit_test_behavior: HitTestBehavior

How to behave during hit testing when deciding how the hit test propagates to children and whether to consider targets behind this scroll view.

Defaults to HitTestBehavior::Opaque.

§restoration_id: Option<String>

Restoration ID to save and restore the scroll offset of the scrollable.

§keyboard_dismiss_behavior: Option<ScrollViewKeyboardDismissBehavior>

How this scroll view will dismiss the keyboard automatically.

If None then it falls back to the inherited ScrollBehavior::get_keyboard_dismiss_behavior.

Implementations§

Source§

impl SingleChildScrollView

Source

pub fn new() -> SingleChildScrollView

Creates a box in which a single widget can be scrolled.

Source

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

Dart SingleChildScrollView(key:).

Source

pub fn scroll_direction(self, scroll_direction: Axis) -> SingleChildScrollView

Dart SingleChildScrollView(scrollDirection:).

Source

pub fn reverse(self, reverse: bool) -> SingleChildScrollView

Dart SingleChildScrollView(reverse:).

Source

pub fn padding( self, padding: impl Into<EdgeInsetsGeometry>, ) -> SingleChildScrollView

Dart SingleChildScrollView(padding:).

Source

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

Dart SingleChildScrollView(controller:).

Source

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

Dart SingleChildScrollView(primary:).

Source

pub fn physics(self, physics: ScrollPhysicsRef) -> SingleChildScrollView

Dart SingleChildScrollView(physics:).

Source

pub fn child<K>(self, child: impl IntoWidget<K>) -> SingleChildScrollView

Dart SingleChildScrollView(child:).

Source

pub fn drag_start_behavior( self, drag_start_behavior: DragStartBehavior, ) -> SingleChildScrollView

Dart SingleChildScrollView(dragStartBehavior:).

Source

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

Dart SingleChildScrollView(clipBehavior:).

Source

pub fn hit_test_behavior( self, hit_test_behavior: HitTestBehavior, ) -> SingleChildScrollView

Dart SingleChildScrollView(hitTestBehavior:).

Source

pub fn restoration_id( self, restoration_id: impl Into<String>, ) -> SingleChildScrollView

Dart SingleChildScrollView(restorationId:).

Source

pub fn keyboard_dismiss_behavior( self, keyboard_dismiss_behavior: ScrollViewKeyboardDismissBehavior, ) -> SingleChildScrollView

Dart SingleChildScrollView(keyboardDismissBehavior:).

Trait Implementations§

Source§

impl Clone for SingleChildScrollView

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SingleChildScrollView

Source§

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

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

impl Default for SingleChildScrollView

Source§

fn default() -> SingleChildScrollView

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

impl StatelessWidget for SingleChildScrollView

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>

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 SingleChildScrollView

§

impl !Send for SingleChildScrollView

§

impl !Sync for SingleChildScrollView

§

impl !UnwindSafe for SingleChildScrollView

§

impl Forget for SingleChildScrollView

§

impl Freeze for SingleChildScrollView
where *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 RcInner<dyn ScrollPhysics> is !null: Freeze, PhantomData<RcInner<dyn ScrollPhysics>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for SingleChildScrollView

§

impl Unpin for SingleChildScrollView
where Rc<dyn Key>: Unpin, NonZero<u32>: Unpin, &'static ScrollControllerVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn ScrollPhysics>: Unpin, Rc<dyn Widget>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for SingleChildScrollView
where *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 RcInner<dyn ScrollPhysics> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ScrollPhysics>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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>