click method

  1. @override
Future<Null> click({
  1. ClickOption? clickOption,
})
override

Clicks on the element with clickOption. clickOption is only used for HTML.

Implementation

@override
Future<Null> click({ClickOption? clickOption}) async {
  await syncFn(() async => _retryWhenStale(() async {
        final element = _single;
        if (element is OptionElement) {
          return _clickOptionElement();
        }

        await _microtask(() => element.dispatchEvent(
            MouseEvent('mousedown', detail: clickOption?.detail ?? 1)));
        await _microtask(() => element.dispatchEvent(
            MouseEvent('mouseup', detail: clickOption?.detail ?? 1)));

        if (element is SvgElement || clickOption != null) {
          final event = MouseEvent('click',
              button: MouseButton.primary.value,
              detail: clickOption?.detail ?? 1,
              clientX: clickOption?.clientX ?? 0,
              clientY: clickOption?.clientY ?? 0,
              screenX: clickOption?.screenX ?? 0,
              screenY: clickOption?.screenY ?? 0);

          return _microtask(() => element.dispatchEvent(event));
        }

        return _microtask(element.click);
      }));
}