DragAndDropLists constructor
DragAndDropLists({
- required List<
DragAndDropListInterface> children, - required OnItemReorder onItemReorder,
- required OnListReorder onListReorder,
- OnItemAdd? onItemAdd,
- OnListAdd? onListAdd,
- OnListDraggingChanged? onListDraggingChanged,
- ListOnWillAccept? listOnWillAccept,
- ListOnAccept? listOnAccept,
- ListTargetOnWillAccept? listTargetOnWillAccept,
- ListTargetOnAccept? listTargetOnAccept,
- OnItemDraggingChanged? onItemDraggingChanged,
- ItemOnWillAccept? itemOnWillAccept,
- ItemOnAccept? itemOnAccept,
- ItemTargetOnWillAccept? itemTargetOnWillAccept,
- ItemTargetOnAccept? itemTargetOnAccept,
- double? itemDraggingWidth,
- Widget? itemGhost,
- double itemGhostOpacity = 0.3,
- int itemSizeAnimationDurationMilliseconds = 150,
- bool itemDragOnLongPress = true,
- Decoration? itemDecorationWhileDragging,
- Widget? itemDivider,
- double? listDraggingWidth,
- Widget? listTarget,
- Widget? listGhost,
- double listGhostOpacity = 0.3,
- int listSizeAnimationDurationMilliseconds = 150,
- bool listDragOnLongPress = true,
- Decoration? listDecoration,
- Decoration? listDecorationWhileDragging,
- Decoration? listInnerDecoration,
- Widget? listDivider,
- bool listDividerOnLastChild = true,
- EdgeInsets? listPadding,
- Widget? contentsWhenEmpty,
- double listWidth = double.infinity,
- double lastItemTargetHeight = 20,
- bool addLastItemTargetHeightToTop = false,
- double lastListTargetSize = 110,
- CrossAxisAlignment verticalAlignment = CrossAxisAlignment.start,
- MainAxisAlignment horizontalAlignment = MainAxisAlignment.start,
- Axis axis = Axis.vertical,
- bool sliverList = false,
- ScrollController? scrollController,
- bool disableScrolling = false,
- DragHandle? listDragHandle,
- DragHandle? itemDragHandle,
- bool constrainDraggingAxis = true,
- bool removeTopPadding = false,
- Key? key,
Implementation
DragAndDropLists({
required this.children,
required this.onItemReorder,
required this.onListReorder,
this.onItemAdd,
this.onListAdd,
this.onListDraggingChanged,
this.listOnWillAccept,
this.listOnAccept,
this.listTargetOnWillAccept,
this.listTargetOnAccept,
this.onItemDraggingChanged,
this.itemOnWillAccept,
this.itemOnAccept,
this.itemTargetOnWillAccept,
this.itemTargetOnAccept,
this.itemDraggingWidth,
this.itemGhost,
this.itemGhostOpacity = 0.3,
this.itemSizeAnimationDurationMilliseconds = 150,
this.itemDragOnLongPress = true,
this.itemDecorationWhileDragging,
this.itemDivider,
this.listDraggingWidth,
this.listTarget,
this.listGhost,
this.listGhostOpacity = 0.3,
this.listSizeAnimationDurationMilliseconds = 150,
this.listDragOnLongPress = true,
this.listDecoration,
this.listDecorationWhileDragging,
this.listInnerDecoration,
this.listDivider,
this.listDividerOnLastChild = true,
this.listPadding,
this.contentsWhenEmpty,
this.listWidth = double.infinity,
this.lastItemTargetHeight = 20,
this.addLastItemTargetHeightToTop = false,
this.lastListTargetSize = 110,
this.verticalAlignment = CrossAxisAlignment.start,
this.horizontalAlignment = MainAxisAlignment.start,
this.axis = Axis.vertical,
this.sliverList = false,
this.scrollController,
this.disableScrolling = false,
this.listDragHandle,
this.itemDragHandle,
this.constrainDraggingAxis = true,
this.removeTopPadding = false,
Key? key,
}) : super(key: key) {
if (listGhost == null &&
children
.where((element) => element is DragAndDropListExpansionInterface)
.isNotEmpty)
throw Exception(
'If using DragAndDropListExpansion, you must provide a non-null listGhost');
if (sliverList && scrollController == null) {
throw Exception(
'A scroll controller must be provided when using sliver lists');
}
if (axis == Axis.horizontal && listWidth == double.infinity) {
throw Exception(
'A finite width must be provided when setting the axis to horizontal');
}
if (axis == Axis.horizontal && sliverList) {
throw Exception(
'Combining a sliver list with a horizontal list is currently unsupported');
}
}