dispatchTouchEvent method

Future<void> dispatchTouchEvent(
  1. @Enum(['touchStart', 'touchEnd', 'touchMove', 'touchCancel']) String type,
  2. List<TouchPoint> touchPoints, {
  3. int? modifiers,
  4. TimeSinceEpoch? timestamp,
})

Dispatches a touch event to the page. type Type of the touch event. TouchEnd and TouchCancel must not contain any touch points, while TouchStart and TouchMove must contains at least one. touchPoints Active touch points on the touch device. One event per any changed point (compared to previous touch event in a sequence) is generated, emulating pressing/moving/releasing points one by one. modifiers Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). timestamp Time at which the event occurred.

Implementation

Future<void> dispatchTouchEvent(
    @Enum(['touchStart', 'touchEnd', 'touchMove', 'touchCancel']) String type,
    List<TouchPoint> touchPoints,
    {int? modifiers,
    TimeSinceEpoch? timestamp}) async {
  assert(const ['touchStart', 'touchEnd', 'touchMove', 'touchCancel']
      .contains(type));
  await _client.send('Input.dispatchTouchEvent', {
    'type': type,
    'touchPoints': [...touchPoints],
    if (modifiers != null) 'modifiers': modifiers,
    if (timestamp != null) 'timestamp': timestamp,
  });
}