Skip to main content

ReorderableList

Struct ReorderableList 

Source
pub struct ReorderableList {
Show 27 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 padding: Option<EdgeInsetsGeometry>, pub scroll_direction: Axis, pub reverse: bool, pub 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>,
}
Expand description

A scrolling container that allows the user to interactively reorder the list items.

This widget is similar to one created by ListView.builder, and uses an IndexedWidgetBuilder to create each item.

It is up to the application to wrap each child (or an internal part of the child such as a drag handle) with a drag listener that will recognize the start of an item drag and then start the reorder by calling ReorderableListState::start_item_drag_reorder. This is most easily achieved by wrapping each child in a ReorderableDragStartListener or a ReorderableDelayedDragStartListener. These will take care of recognizing the start of a drag gesture and call the list state’s ReorderableListState::start_item_drag_reorder method.

This widget’s ReorderableListState can be used to manually start an item reorder, or cancel a current drag. To refer to the ReorderableListState either provide a GlobalKey or use the static ReorderableList::of method from an item’s build method.

See also:

  • SliverReorderableList, a sliver list that allows the user to reorder its items.
  • ReorderableListView, a Material Design list that allows the user to reorder its items.

Fields§

§key: Option<KeyRef>§item_builder: IndexedWidgetBuilder

Called, as needed, to build list item widgets.

List items are only built when they’re scrolled into view.

The IndexedWidgetBuilder index parameter indicates the item’s position in the list. The value of the index parameter will be between zero and one less than item_count. All items in the list must have a unique Key, and should have some kind of listener to start the drag (usually a ReorderableDragStartListener or ReorderableDelayedDragStartListener).

§item_count: i32

The number of items in the list.

It must be a non-negative integer. When zero, nothing is displayed and the widget occupies no space.

§on_reorder: Option<ReorderCallback>

A callback used by the list to report that a list item has been dragged to a new location in the list and the application should update the order of the items.

If old_index is before new_index, removing the item at old_index from the list will reduce the list’s length by one. Implementations will need to account for this when inserting before new_index.

Deprecated in favor of on_reorder_item, which simplifies the reordering logic by automatically handling index adjustments. To migrate, remove the manual adjustment of new_index when items are moved downward in the list.

§on_reorder_item: Option<ReorderCallback>

A callback used by the list to report that a list item has been dragged to a new location in the list and the application should update the order of the items.

§on_reorder_start: Option<ReorderIndexCallback>

A callback that is called when an item drag has started.

The index parameter of the callback is the index of the selected item.

See also:

  • on_reorder_end, which is a called when the dragged item is dropped.
  • on_reorder_item, which reports that a list item has been dragged to a new location.
§on_reorder_end: Option<ReorderIndexCallback>

A callback that is called when the dragged item is dropped.

The index parameter of the callback is the index where the item is dropped. Unlike on_reorder_item, this is called even when the list item is dropped in the same location.

See also:

§proxy_decorator: Option<ReorderItemProxyDecorator>

A callback that allows the app to add an animated decoration around an item when it is being dragged.

§padding: Option<EdgeInsetsGeometry>

The amount of space by which to inset the list contents.

It defaults to EdgeInsets.all(0).

§scroll_direction: Axis

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

§reverse: bool

Whether the scroll view scrolls in the reading direction.

§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.

§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.

§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>

The ScrollViewKeyboardDismissBehavior defines how this scroll view will dismiss 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>

If non-None, forces the children to have the given extent in the scroll direction.

§item_extent_builder: Option<ItemExtentBuilder>

Called to get the item extent of the children in the scroll direction.

§prototype_item: Option<WidgetRef>

If non-None, forces the children to have the same extent as the given widget in the scroll direction.

§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>

A callback used to provide drag boundaries during drag-and-drop reordering.

If None, the delegate returned by DragBoundary::for_rect_maybe_of will be used. Defaults to None.

Implementations§

Source§

impl ReorderableList

Source

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

Creates a scrolling container that allows the user to interactively reorder the list items.

The item_count must be greater than or equal to zero.

Source

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

Dart ReorderableList(key:).

Source

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

👎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 ReorderableList(onReorder:).

Source

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

Dart ReorderableList(onReorderItem:).

Source

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

Dart ReorderableList(onReorderStart:).

Source

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

Dart ReorderableList(onReorderEnd:).

Source

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

Dart ReorderableList(itemExtent:).

Source

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

Dart ReorderableList(itemExtentBuilder:).

Source

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

Dart ReorderableList(prototypeItem:).

Source

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

Dart ReorderableList(proxyDecorator:).

Source

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

Dart ReorderableList(padding:).

Source

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

Dart ReorderableList(scrollDirection:).

Source

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

Dart ReorderableList(reverse:).

Source

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

Dart ReorderableList(controller:).

Source

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

Dart ReorderableList(primary:).

Source

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

Dart ReorderableList(physics:).

Source

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

Dart ReorderableList(shrinkWrap:).

Source

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

Dart ReorderableList(anchor:).

Source

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

👎Deprecated:

Use scroll_cache_extent instead.

Dart ReorderableList(cacheExtent:).

Source

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

Dart ReorderableList(scrollCacheExtent:).

Source

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

Dart ReorderableList(dragStartBehavior:).

Source

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

Dart ReorderableList(keyboardDismissBehavior:).

Source

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

Dart ReorderableList(restorationId:).

Source

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

Dart ReorderableList(clipBehavior:).

Source

pub fn auto_scroller_velocity_scalar(self, value: f64) -> ReorderableList

Dart ReorderableList(autoScrollerVelocityScalar:).

Source

pub fn drag_boundary_provider( self, drag_boundary_provider: impl Fn(&mut App, BuildContext) -> Option<Box<dyn DragBoundaryDelegate<Rect>>> + 'static, ) -> ReorderableList

Dart ReorderableList(dragBoundaryProvider:).

Source

pub fn of(app: &App, context: BuildContext) -> Handle<ReorderableListState>

The state from the closest instance of this class that encloses the given context.

This method is typically used by ReorderableList item widgets that insert or remove items in response to user input.

If no ReorderableList surrounds the given context, then this function will panic.

This method can be expensive (it walks the element tree).

See also:

Source

pub fn maybe_of( app: &App, context: BuildContext, ) -> Option<Handle<ReorderableListState>>

The state from the closest instance of this class that encloses the given context.

This method is typically used by ReorderableList item widgets that insert or remove items in response to user input.

If no ReorderableList surrounds the context given, then this function will return None.

This method can be expensive (it walks the element tree).

See also:

Trait Implementations§

Source§

impl Debug for ReorderableList

Source§

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

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

impl StatefulWidget for ReorderableList

Source§

type State = ReorderableListState

The state this widget creates.
Source§

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

Source§

fn debug_check_constructor(&self)

Source§

fn create_state(&self) -> ReorderableListState

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>

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 ReorderableList

§

impl !Send for ReorderableList

§

impl !Sync for ReorderableList

§

impl !UnwindSafe for ReorderableList

§

impl Forget for ReorderableList

§

impl Freeze for ReorderableList
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, 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 Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: 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,

§

impl Move for ReorderableList

§

impl Unpin for ReorderableList
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, 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 Widget>: Unpin, Rc<dyn Fn(&mut App, AnyElement) -> Option<Box<dyn DragBoundaryDelegate<Rect>>>>: Unpin,

§

impl UnsafeUnpin for ReorderableList
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, 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 Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: 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,

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>