isWithinBoundsOfWeb static method

bool isWithinBoundsOfWeb(
  1. BuildContext element,
  2. Offset position,
  3. int screenWidth,
  4. int screenHeight,
)

Implementation

static bool isWithinBoundsOfWeb(BuildContext element, Offset position,
    int screenWidth, int screenHeight) {
  try {
    int x = (position.dx).round();
    int y = (position.dy).round();
    int width = (element.size?.width ?? 0).round();
    int height = (element.size?.height ?? 0).round();
    return x >= 0 &&
        y >= 0 &&
        (x + width) <= screenWidth &&
        (y + height) <= screenHeight &&
        width > 0 &&
        height > 0;
  } catch (e) {
    debugPrint("Error in isWithinBounds: $e");
    return false;
  }
}