moveListRight method

void moveListRight()

Implementation

void moveListRight() {
  var list = widget.lists![draggedListIndex!];
  var listState = listStates[draggedListIndex!];
  widget.lists!.removeAt(draggedListIndex!);
  listStates.removeAt(draggedListIndex!);
  if (draggedListIndex != null) {
    draggedListIndex = draggedListIndex! + 1;
  }
  widget.lists!.insert(draggedListIndex!, list);
  listStates.insert(draggedListIndex!, listState);
  canDrag = false;
  if (boardViewController.hasClients) {
    int? tempListIndex = draggedListIndex;
    boardViewController
        .animateTo(draggedListIndex! * widget.width,
            duration: const Duration(milliseconds: 400), curve: Curves.ease)
        .whenComplete(() {
      RenderBox object =
          listStates[tempListIndex!].context.findRenderObject() as RenderBox;
      Offset pos = object.localToGlobal(Offset.zero);
      leftListX = pos.dx;
      rightListX = pos.dx + object.size.width;
      Future.delayed(Duration(milliseconds: widget.dragDelay), () {
        canDrag = true;
      });
    });
  }
  if (mounted) {
    setState(() {});
  }
}