moveToElementTopLeft method Null safety

Future<void> moveToElementTopLeft(
  1. WebElement element,
  2. {int? xOffset,
  3. int? yOffset}
)

Moves to element, with an offset of xOffset and yOffset based on the top left corner of element.

Implementation

Future<void> moveToElementTopLeft(WebElement element,
    {int? xOffset, int? yOffset}) async {
  if (_handler is W3cWebDriverHandler) {
    final size = await element.size;
    await moveTo(
        element: element,
        xOffset: (xOffset ?? 0) - size.width ~/ 2,
        yOffset: (yOffset ?? 0) - size.height ~/ 2);
  } else {
    await moveTo(element: element, xOffset: xOffset, yOffset: yOffset);
  }
}