onDragStart method

  1. @override
dynamic onDragStart(
  1. DragStartDetails dragStartDetails,
  2. DragDirection direction
)
override

Implementation

@override
onDragStart(DragStartDetails dragStartDetails, DragDirection direction) {

  double height = widget.model.constraints.maxHeight ?? 0;
  double width = widget.model.constraints.maxWidth ?? 0;

  switch (direction) {

    // vertical drag
    case DragDirection.vertical:
      if (dragStartDetails.localPosition.dy < dragEdge &&
          activeDrawer == null &&
          widget.model.drawerExists(Drawers.top)) {
        setState(() {
          fromBottom = height;
          activeDrawer = Drawers.top;
        });
      }
      else if (dragStartDetails.localPosition.dy >
          (height - dragEdge) &&
          activeDrawer == null &&
          widget.model.drawerExists(Drawers.bottom)) {
        setState(() {
          fromTop = height;
          activeDrawer = Drawers.bottom;
        });
      }
      break;

    // horizontal drag
    case DragDirection.horizontal:
      if (dragStartDetails.localPosition.dx < dragEdge &&
          activeDrawer == null &&
          widget.model.drawerExists(Drawers.left)) {
        setState(() {
          fromRight = width;
          activeDrawer = Drawers.left;
        });
      }
      else if (dragStartDetails.localPosition.dx >
          (width - dragEdge) &&
          activeDrawer == null &&
          widget.model.drawerExists(Drawers.right)) {
        setState(() {
          fromLeft = width;
          activeDrawer = Drawers.right;
        });
      }
      break;
  }

}