maybeListScroll method

void maybeListScroll()

Implementation

void maybeListScroll() async {
  var prov = ref.read(ProviderList.boardProvider);
  if (prov.board.isElementDragged == false || scrolling) {
    return;
  }
  var controller =
      prov.board.lists[prov.board.dragItemOfListIndex!].scrollController;
  if (controller.offset < controller.position.maxScrollExtent &&
      prov.valueNotifier.value.dy >
          controller.position.viewportDimension - 50) {
    scrolling = true;
    scrollingDown = true;
    if (prov.board.listScrollConfig == null) {
      await controller.animateTo(controller.offset + 45,
          duration: const Duration(milliseconds: 250), curve: Curves.linear);
    } else {
      await controller.animateTo(
          prov.board.listScrollConfig!.offset + controller.offset,
          duration: prov.board.listScrollConfig!.duration,
          curve: prov.board.listScrollConfig!.curve);
    }
    scrolling = false;
    scrollingDown = false;

    maybeListScroll();
  } else if (controller.offset > 0 && prov.valueNotifier.value.dy < 100) {
    scrolling = true;
    scrollingUp = true;
    if (prov.board.listScrollConfig == null) {
      await controller.animateTo(controller.offset - 45,
          duration: const Duration(milliseconds: 250), curve: Curves.linear);
    } else {
      await controller.animateTo(
          controller.offset - prov.board.listScrollConfig!.offset,
          duration: prov.board.listScrollConfig!.duration,
          curve: prov.board.listScrollConfig!.curve);
    }
    scrolling = false;
    scrollingUp = false;
    maybeListScroll();
  } else {
    return;
  }
}