Skip to main content

ReorderableListView

Struct ReorderableListView 

Source
pub struct ReorderableListView {
Show 31 fields pub key: Option<KeyRef>, pub item_builder: IndexedWidgetBuilder, pub item_count: i32, pub on_reorder: Option<ReorderCallback>, pub on_reorder_item: Option<ReorderCallback>, pub on_reorder_start: Option<ReorderIndexCallback>, pub on_reorder_end: Option<ReorderIndexCallback>, pub proxy_decorator: Option<ReorderItemProxyDecorator>, pub build_default_drag_handles: bool, pub padding: Option<EdgeInsets>, pub header: Option<WidgetRef>, pub footer: Option<WidgetRef>, pub scroll_direction: Axis, pub reverse: bool, pub scroll_controller: Option<ScrollControllerRef>, pub primary: Option<bool>, pub physics: Option<ScrollPhysicsRef>, pub shrink_wrap: bool, pub anchor: f64, pub cache_extent: Option<f64>, pub scroll_cache_extent: Option<ScrollCacheExtent>, pub drag_start_behavior: DragStartBehavior, pub keyboard_dismiss_behavior: Option<ScrollViewKeyboardDismissBehavior>, pub restoration_id: Option<String>, pub clip_behavior: Clip, pub item_extent: Option<f64>, pub item_extent_builder: Option<ItemExtentBuilder>, pub prototype_item: Option<WidgetRef>, pub auto_scroller_velocity_scalar: Option<f64>, pub drag_boundary_provider: Option<ReorderDragBoundaryProvider>, pub mouse_cursor: Option<MouseCursorRef>,
}
Expand description

A list whose items the user can interactively reorder by dragging.

This sample shows by dragging the user can reorder the items of the list. The on_reorder_item parameter will be called when a child widget is dragged to a new position.

By default, on desktop platforms each item will have a drag handle added on top of it that will allow the user to grab it to move the item. On mobile platforms, no drag handle will be added, but when the user long presses anywhere on the item it will start moving the item. Displaying drag handles can be controlled with build_default_drag_handles.

All list items must have a key.

While a drag is underway, the widget returned by the proxy_decorator callback serves as a “proxy” (a substitute) for the item in the list. The proxy is created with the original list item as its child. The default one wraps the dragged item in a Material widget and animates its elevation.

Fields§

§key: Option<KeyRef>§item_builder: IndexedWidgetBuilder

See ReorderableList::item_builder.

§item_count: i32

See ReorderableList::item_count.

§on_reorder: Option<ReorderCallback>

See ReorderableList::on_reorder.

Deprecated: use on_reorder_item.

§on_reorder_item: Option<ReorderCallback>

See ReorderableList::on_reorder_item.

§on_reorder_start: Option<ReorderIndexCallback>

See ReorderableList::on_reorder_start.

§on_reorder_end: Option<ReorderIndexCallback>

See ReorderableList::on_reorder_end.

§proxy_decorator: Option<ReorderItemProxyDecorator>

See ReorderableList::proxy_decorator.

§build_default_drag_handles: bool

If true: on desktop platforms, a drag handle is stacked over the center of each item’s trailing edge; on mobile platforms, a long press anywhere on the item starts a drag.

The default desktop drag handle is just an Icons::drag_handle wrapped by a ReorderableDragStartListener. On mobile platforms, the entire item is wrapped with a ReorderableDelayedDragStartListener.

To change the appearance or the layout of the drag handles, make this parameter false and wrap each list item, or a widget within each list item, with ReorderableDragStartListener or ReorderableDelayedDragStartListener.

§padding: Option<EdgeInsets>

See ReorderableList::padding.

§header: Option<WidgetRef>

A non-reorderable header item to show before the items of the list.

If None, no header will appear before the list.

§footer: Option<WidgetRef>

A non-reorderable footer item to show after the items of the list.

If None, no footer will appear after the list.

§scroll_direction: Axis

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

§reverse: bool

Whether the scroll view scrolls in the reading direction.

§scroll_controller: Option<ScrollControllerRef>

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

§primary: Option<bool>

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

Defaults to true when scroll_direction is Axis::Vertical and scroll_controller is None.

§physics: Option<ScrollPhysicsRef>

How the scroll view should respond to user input.

§shrink_wrap: bool

Whether the extent of the scroll view in the scroll direction should be determined by the contents being viewed.

§anchor: f64

The relative position of the zero scroll offset.

For more information, see ScrollView::anchor.

§cache_extent: Option<f64>

The viewport has an area before and after the visible area to cache items that are about to become visible when the user scrolls.

Deprecated: use scroll_cache_extent instead.

§scroll_cache_extent: Option<ScrollCacheExtent>

The amount of additional content to display and lay out around the viewport.

§drag_start_behavior: DragStartBehavior

Determines the way that drag start behavior is handled.

§keyboard_dismiss_behavior: Option<ScrollViewKeyboardDismissBehavior>

How this scroll view dismisses the keyboard automatically.

If it is None then it will fallback to the inherited ScrollBehavior::get_keyboard_dismiss_behavior.

§restoration_id: Option<String>

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

§clip_behavior: Clip

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

Defaults to Clip::HardEdge.

§item_extent: Option<f64>

See ReorderableList::item_extent.

§item_extent_builder: Option<ItemExtentBuilder>

See ReorderableList::item_extent_builder.

§prototype_item: Option<WidgetRef>

See ReorderableList::prototype_item.

§auto_scroller_velocity_scalar: Option<f64>

The velocity scalar per pixel over scroll of the auto scroller.

Defaults to 50 if not set or set to None.

§drag_boundary_provider: Option<ReorderDragBoundaryProvider>

See ReorderableList::drag_boundary_provider.

§mouse_cursor: Option<MouseCursorRef>

The cursor for a mouse pointer when it enters or is hovering over the drag handle.

If mouse_cursor is a WidgetStateMouseCursor, WidgetStateProperty::resolve is used for the following WidgetStates:

If this property is None, SystemMouseCursors::GRAB will be used when hovering, and SystemMouseCursors::GRABBING when dragging.

Implementations§

Source§

impl ReorderableListView

Source

pub fn new(children: impl IntoIterator<Item = WidgetRef>) -> ReorderableListView

Creates a reorderable list from a pre-built list of widgets.

This constructor is appropriate for lists with a small number of children because constructing the list requires doing work for every child that could possibly be displayed in the list view instead of just those children that are actually visible.

See also:

  • builder, which allows you to build a reorderable list where the items are built as needed when scrolling the list.
Source

pub fn builder( item_builder: impl Fn(&mut App, BuildContext, i32) -> WidgetRef + 'static, item_count: i32, ) -> ReorderableListView

Creates a reorderable list from widget items that are created on demand.

This constructor is appropriate for list views with a large number of children because the builder is called only for those children that are actually visible.

The item_builder callback will be called only with indices greater than or equal to zero and less than item_count.

The item_builder should always return a widget, and actually create the widget instances when called. Avoid using a builder that returns a previously-constructed widget; if the list view’s children are created in advance, or all at once when the ReorderableListView itself is created, it is more efficient to use new. Even more efficient, however, is to create the instances on demand using this constructor’s item_builder callback.

See also:

  • new, which allows you to build a reorderable list with all the items passed into the constructor.
Source

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

Dart ReorderableListView(key:).

Source

pub fn on_reorder( self, on_reorder: impl Fn(&mut App, i32, i32) + 'static, ) -> ReorderableListView

👎Deprecated:

Use the on_reorder_item callback instead. The on_reorder_item callback adjusts the new_index parameter for a removed item at the old_index.

Dart ReorderableListView(onReorder:).

Source

pub fn on_reorder_item( self, on_reorder_item: impl Fn(&mut App, i32, i32) + 'static, ) -> ReorderableListView

Dart ReorderableListView(onReorderItem:).

Source

pub fn on_reorder_start( self, on_reorder_start: impl Fn(&mut App, i32) + 'static, ) -> ReorderableListView

Dart ReorderableListView(onReorderStart:).

Source

pub fn on_reorder_end( self, on_reorder_end: impl Fn(&mut App, i32) + 'static, ) -> ReorderableListView

Dart ReorderableListView(onReorderEnd:).

Source

pub fn item_extent(self, item_extent: f64) -> ReorderableListView

Dart ReorderableListView(itemExtent:).

Source

pub fn item_extent_builder( self, item_extent_builder: ItemExtentBuilder, ) -> ReorderableListView

Dart ReorderableListView(itemExtentBuilder:).

Source

pub fn prototype_item<K>( self, prototype_item: impl IntoWidget<K>, ) -> ReorderableListView

Dart ReorderableListView(prototypeItem:).

Source

pub fn proxy_decorator( self, proxy_decorator: impl Fn(&mut App, WidgetRef, i32, AnimationRef<f64>) -> WidgetRef + 'static, ) -> ReorderableListView

Dart ReorderableListView(proxyDecorator:).

Source

pub fn build_default_drag_handles( self, build_default_drag_handles: bool, ) -> ReorderableListView

Dart ReorderableListView(buildDefaultDragHandles:).

Source

pub fn padding(self, padding: EdgeInsets) -> ReorderableListView

Dart ReorderableListView(padding:).

Source

pub fn header<K>(self, header: impl IntoWidget<K>) -> ReorderableListView

Dart ReorderableListView(header:).

Source

pub fn footer<K>(self, footer: impl IntoWidget<K>) -> ReorderableListView

Dart ReorderableListView(footer:).

Source

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

Dart ReorderableListView(scrollDirection:).

Source

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

Dart ReorderableListView(reverse:).

Source

pub fn scroll_controller( self, scroll_controller: ScrollControllerRef, ) -> ReorderableListView

Dart ReorderableListView(scrollController:).

Source

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

Dart ReorderableListView(primary:).

Source

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

Dart ReorderableListView(physics:).

Source

pub fn shrink_wrap(self, shrink_wrap: bool) -> ReorderableListView

Dart ReorderableListView(shrinkWrap:).

Source

pub fn anchor(self, anchor: f64) -> ReorderableListView

Dart ReorderableListView(anchor:).

Source

pub fn cache_extent(self, cache_extent: f64) -> ReorderableListView

👎Deprecated:

Use scroll_cache_extent instead.

Dart ReorderableListView(cacheExtent:).

Source

pub fn scroll_cache_extent( self, scroll_cache_extent: ScrollCacheExtent, ) -> ReorderableListView

Dart ReorderableListView(scrollCacheExtent:).

Source

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

Dart ReorderableListView(dragStartBehavior:).

Source

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

Dart ReorderableListView(keyboardDismissBehavior:).

Source

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

Dart ReorderableListView(restorationId:).

Source

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

Dart ReorderableListView(clipBehavior:).

Source

pub fn auto_scroller_velocity_scalar( self, auto_scroller_velocity_scalar: f64, ) -> ReorderableListView

Dart ReorderableListView(autoScrollerVelocityScalar:).

Source

pub fn drag_boundary_provider( self, drag_boundary_provider: ReorderDragBoundaryProvider, ) -> ReorderableListView

Dart ReorderableListView(dragBoundaryProvider:).

Source

pub fn mouse_cursor( self, mouse_cursor: impl Into<MouseCursorRef>, ) -> ReorderableListView

Dart ReorderableListView(mouseCursor:).

Trait Implementations§

Source§

impl Debug for ReorderableListView

Source§

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

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

impl StatefulWidget for ReorderableListView

Source§

type State = ReorderableListViewState

The state this widget creates.
Source§

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

Source§

fn debug_check_constructor(&self)

Source§

fn create_state(&self) -> ReorderableListViewState

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 ReorderableListView

§

impl !Send for ReorderableListView

§

impl !Sync for ReorderableListView

§

impl !UnwindSafe for ReorderableListView

§

impl Forget for ReorderableListView

§

impl Freeze for ReorderableListView
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, i32) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, i32) -> Rc<dyn Widget>>>: Freeze, *const RcInner<dyn Fn(&mut App, i32, i32)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, i32, i32)>>: Freeze, *const RcInner<dyn Fn(&mut App, i32)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, i32)>>: Freeze, *const RcInner<dyn Fn(&mut App, Rc<dyn Widget>, i32, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, Rc<dyn Widget>, i32, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>>: 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 ScrollPhysics> is !null: Freeze, PhantomData<RcInner<dyn ScrollPhysics>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const RcInner<dyn Fn(i32, SliverLayoutDimensions) -> Option<f64>> is !null: Freeze, PhantomData<RcInner<dyn Fn(i32, SliverLayoutDimensions) -> Option<f64>>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement) -> Option<Box<dyn DragBoundaryDelegate<Rect>>>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Option<Box<dyn DragBoundaryDelegate<Rect>>>>>: Freeze, *const RcInner<dyn MouseCursor> is !null: Freeze, PhantomData<RcInner<dyn MouseCursor>>: Freeze,

§

impl Move for ReorderableListView

§

impl Unpin for ReorderableListView
where Rc<dyn Key>: Unpin, Rc<dyn Fn(&mut App, AnyElement, i32) -> Rc<dyn Widget>>: Unpin, Rc<dyn Fn(&mut App, i32, i32)>: Unpin, Rc<dyn Fn(&mut App, i32)>: Unpin, Rc<dyn Fn(&mut App, Rc<dyn Widget>, i32, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>: Unpin, Rc<dyn Widget>: Unpin, NonZero<u32>: Unpin, &'static ScrollControllerVTable: Unpin, Rc<Keep>: Unpin, Rc<dyn ScrollPhysics>: Unpin, *const u8 is !null: Unpin, Rc<dyn Fn(i32, SliverLayoutDimensions) -> Option<f64>>: Unpin, Rc<dyn Fn(&mut App, AnyElement) -> Option<Box<dyn DragBoundaryDelegate<Rect>>>>: Unpin, Rc<dyn MouseCursor>: Unpin,

§

impl UnsafeUnpin for ReorderableListView
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, i32) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, i32) -> Rc<dyn Widget>>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, i32, i32)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, i32, i32)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, i32)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, i32)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, Rc<dyn Widget>, i32, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, Rc<dyn Widget>, i32, Retained<AnyAnimation<f64>>) -> Rc<dyn Widget>>>: 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 ScrollPhysics> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ScrollPhysics>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<dyn Fn(i32, SliverLayoutDimensions) -> Option<f64>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(i32, SliverLayoutDimensions) -> Option<f64>>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement) -> Option<Box<dyn DragBoundaryDelegate<Rect>>>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Option<Box<dyn DragBoundaryDelegate<Rect>>>>>: UnsafeUnpin, *const RcInner<dyn MouseCursor> is !null: UnsafeUnpin, PhantomData<RcInner<dyn MouseCursor>>: 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<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>