sendKeyEvent method

Future<void> sendKeyEvent (
  1. LogicalKeyboardKey key,
  2. {String platform: 'android'}
)

Simulates sending physical key down and up events through the system channel.

This only simulates key events coming from a physical keyboard, not from a soft keyboard.

Specify platform as one of the platforms allowed in Platform.operatingSystem to make the event appear to be from that type of system. Defaults to "android". Must not be null. Some platforms (e.g. Windows, iOS) are not yet supported.

Keys that are down when the test completes are cleared after each test.

This method sends both the key down and the key up events, to simulate a key press. To simulate individual down and/or up events, see sendKeyDownEvent and sendKeyUpEvent.

See also:

Implementation

Future<void> sendKeyEvent(LogicalKeyboardKey key, { String platform = 'android' }) async {
  assert(platform != null);
  await simulateKeyDownEvent(key, platform: platform);
  // Internally wrapped in async guard.
  return simulateKeyUpEvent(key, platform: platform);
}