Reorderable class
Ordering children in a Wrap that can be drag and dropped.
Simple way of drag and drop children that were built inside a Wrap.
To enable the possibility of the drag and drop, it's important to build all children inside a Wrap. After that every child is added to the entity GridItemEntity that contains the position and orderId of the build item. When all items are added to new map animatedChildren, the widget is reconstructing the wrap inside a Container. This Container has the same size as the Wrap. Inside the Container, all children are rebuild with a Positioned widget. At the end, the same widget is build without a Wrap but now it's possible to update the positions of the widgets with a drag and drop.
A list of children that are build inside a Wrap.
Using spacing adds a space in vertical direction between children. The default value is 8.
Using runSpacing adds a space in horizontal direction between children. The default value is 8.
enableAnimation is enabling the animation of changing the positions of children after drag and drop. The default value is true.
With enableLongPress you can decide if the user needs a long press to move the item around. The default value is true.
onReorder always give you the old and new index of the moved children. Make sure to update your list of children that you used to display your data. See more on the example.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- Reorderable
- Implemented types
Constructors
-
Reorderable.new({required List<
Widget> children, required ReorderableType reorderableType, required ReorderCallback onReorder, List<int> lockedChildren = const [], double spacing = 8.0, double runSpacing = 8.0, bool enableAnimation = true, bool enableLongPress = true, bool enableReorder = true, Duration longPressDelay = kLongPressTimeout, double mainAxisSpacing = 0.0, Clip clipBehavior = Clip.hardEdge, double maxCrossAxisExtent = 0.0, double crossAxisSpacing = 0.0, SliverGridDelegate gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), double childAspectRatio = 1.0, int? crossAxisCount, ScrollPhysics? physics, EdgeInsetsGeometry? padding, BoxDecoration? dragChildBoxDecoration, Key? key}) -
const
Properties
- childAspectRatio → double
-
final
-
children
→ List<
Widget> -
Default Parameter
final
- clipBehavior → Clip
-
final
- crossAxisCount → int?
-
GridView
final
- crossAxisSpacing → double
-
final
- dragChildBoxDecoration → BoxDecoration?
-
Define a custom BoxDecoration when dragging the child.
final
- enableAnimation → bool
-
By default animation is enabled when the position of the items changes
final
- enableLongPress → bool
-
By default long press is enabled when tapping an item
final
- enableReorder → bool
-
final
- gridDelegate → SliverGridDelegate
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
lockedChildren
→ List<
int> -
final
- longPressDelay → Duration
-
By default it has a duration of 500ms before an item can be moved.
final
- mainAxisSpacing → double
-
final
- maxCrossAxisExtent → double
-
final
- onReorder → ReorderCallback
-
Every a child changes his position, this function is called.
final
- padding → EdgeInsetsGeometry?
-
final
- physics → ScrollPhysics?
-
final
- reorderableType → ReorderableType
-
Other
final
- runSpacing → double
-
Spacing between displayed items in vertical direction
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- spacing → double
-
Wrap
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< Reorderable> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited