content: import 'package:flutter/material.dart';
  
  class EasyGestureConfig {
    //Vertical swipe configuration options
    final double verticalSwipeMaxWidthThreshold;
    final double verticalSwipeMinDisplacement;
    final double verticalSwipeMinVelocity;
  
    //Horizontal swipe configuration options
    final double horizontalSwipeMaxHeightThreshold;
    final double horizontalSwipeMinDisplacement;
    final double horizontalSwipeMinVelocity;
  
    final HitTestBehavior behavior;
  
    EasyGestureConfig({
      this.verticalSwipeMaxWidthThreshold = 50.0,
      this.verticalSwipeMinDisplacement = 100.0,
      this.verticalSwipeMinVelocity = 300.0,
      this.horizontalSwipeMaxHeightThreshold = 50.0,
      this.horizontalSwipeMinDisplacement = 100.0,
      this.horizontalSwipeMinVelocity = 300.0,
      this.behavior = HitTestBehavior.opaque,
    });
  }
  
  class EasyGestureDetector extends StatelessWidget {
    final Widget child;
    final Function()? onSwipeUp;
    final Function()? onSwipeDown;
    final Function()? onSwipeLeft;
    final Function()? onSwipeRight;
    final Function()? onTap;
    final Function()? onDoubleTap;
    final Function()? onLongPress;
    final Function(LongPressEndDetails)? onLongPressPositioned;
    final EasyGestureConfig swipeConfiguration;
  
    EasyGestureDetector(
        {required this.child,
        this.onTap,
        this.onDoubleTap,
        this.onSwipeUp,
        this.onSwipeDown,
        this.onSwipeLeft,
        this.onSwipeRight,
        this.onLongPress,
        this.onLongPressPositioned,
        EasyGestureConfig? swipeConfiguration})
        : this.swipeConfiguration = swipeConfiguration == null
              ? EasyGestureConfig()
              : swipeConfiguration;
  
    @override
    Widget build(BuildContext context) {
      //Vertical drag details
      late DragStartDetails startVerticalDragDetails;
      late DragUpdateDetails updateVerticalDragDetails;
  
      //Horizontal drag details
      late DragStartDetails startHorizontalDragDetails;
      late DragUpdateDetails updateHorizontalDragDetails;
  
      return GestureDetector(
        child: child,
        onTap: () {
          if (onTap != null) {
            onTap!();
          }
        },
        onDoubleTap: () {
          if (onDoubleTap != null) {
            onDoubleTap!();
          }
        },
        onLongPress: () {
          if (onLongPress != null) {
            onLongPress!();
          }
        },
        onLongPressEnd: (detail) {
          if (onLongPressPositioned != null) {
            onLongPressPositioned!(detail);
          }
        },
        onVerticalDragStart: (dragDetails) {
          startVerticalDragDetails = dragDetails;
        },
        onVerticalDragUpdate: (dragDetails) {
          updateVerticalDragDetails = dragDetails;
        },
        onVerticalDragEnd: (endDetails) {
          double dx = updateVerticalDragDetails.globalPosition.dx -
              startVerticalDragDetails.globalPosition.dx;
          double dy = updateVerticalDragDetails.globalPosition.dy -
              startVerticalDragDetails.globalPosition.dy;
          double velocity = endDetails.primaryVelocity ?? 0;
  
          //Convert values to be positive
          if (dx < 0) dx = -dx;
          if (dy < 0) dy = -dy;
          double positiveVelocity = velocity < 0 ? -velocity : velocity;
  
          if (dx > swipeConfiguration.verticalSwipeMaxWidthThreshold) return;
          if (dy < swipeConfiguration.verticalSwipeMinDisplacement) return;
          if (positiveVelocity < swipeConfiguration.verticalSwipeMinVelocity)
            return;
  
          if (velocity < 0) {
            //Swipe Up
            if (onSwipeUp != null) {
              onSwipeUp!();
            }
          } else {
            //Swipe Down
            if (onSwipeDown != null) {
              onSwipeDown!();
            }
          }
        },
        onHorizontalDragStart: (dragDetails) {
          startHorizontalDragDetails = dragDetails;
        },
        onHorizontalDragUpdate: (dragDetails) {
          updateHorizontalDragDetails = dragDetails;
        },
        onHorizontalDragEnd: (endDetails) {
          double dx = updateHorizontalDragDetails.globalPosition.dx -
              startHorizontalDragDetails.globalPosition.dx;
          double dy = updateHorizontalDragDetails.globalPosition.dy -
              startHorizontalDragDetails.globalPosition.dy;
          double velocity = endDetails.primaryVelocity ?? 0;
  
          if (dx < 0) dx = -dx;
          if (dy < 0) dy = -dy;
          double positiveVelocity = velocity < 0 ? -velocity : velocity;
  
          if (dx < swipeConfiguration.horizontalSwipeMinDisplacement) return;
          if (dy > swipeConfiguration.horizontalSwipeMaxHeightThreshold) return;
          if (positiveVelocity < swipeConfiguration.horizontalSwipeMinVelocity)
            return;
  
          if (velocity < 0) {
            //Swipe Up
            if (onSwipeLeft != null) {
              onSwipeLeft!();
            }
          } else {
            //Swipe Down
            if (onSwipeRight != null) {
              onSwipeRight!();
            }
          }
        },
      );
    }
  }
  