isLastItemDragged method

bool isLastItemDragged({
  1. required int listIndex,
  2. required int itemIndex,
})

Implementation

bool isLastItemDragged({required int listIndex, required int itemIndex}) {
  var prov = ref.read(ProviderList.boardProvider);
  var item = prov.board.lists[listIndex].items[itemIndex];
  if (prov.draggedItemState!.itemIndex == itemIndex &&
      prov.draggedItemState!.listIndex == listIndex &&
      prov.board.lists[listIndex].items.length - 1 == itemIndex &&
      prov.board.dragItemIndex == itemIndex &&
      prov.board.dragItemOfListIndex == listIndex) {
    return true;
  }

  if ((prov.draggedItemState!.itemIndex == itemIndex &&
      prov.draggedItemState!.listIndex == listIndex &&
      prov.board.dragItemOfListIndex == listIndex &&
      prov.board.lists[listIndex].items.length - 1 == itemIndex &&
      ((prov.draggedItemState!.height * 0.6) + prov.valueNotifier.value.dy >
          item.y! + item.height!))) {
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {});
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      //     log("PREVIOUS |${prov.board.dragItemOfListIndex}| LIST= ${prov.board.dragItemIndex}");

      // if (isItemHidden) {
      //   prov.move = "DOWN";
      // }
      prov.board.lists[prov.board.dragItemOfListIndex!]
              .items[prov.board.dragItemIndex!].child =
          prov.board.lists[prov.board.dragItemOfListIndex!]
              .items[prov.board.dragItemIndex!].prevChild;
      prov.board.lists[prov.board.dragItemOfListIndex!]
          .items[prov.board.dragItemIndex!].setState!();
      prov.board.dragItemIndex = itemIndex;
      prov.board.dragItemOfListIndex = listIndex;

      // log("UP/DOWN $listIndex $itemIndex");
      item.setState!();
    });
    return true;
  }
  return false;
}