simulateKeyUpEvent method

Future<void> simulateKeyUpEvent (
  1. LogicalKeyboardKey key,
  2. {String platform,
  3. PhysicalKeyboardKey physicalKey}

Simulates sending a hardware key up event through the system channel.

This only simulates key presses 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 the operating system that the test is running on. Some platforms (e.g. Windows, iOS) are not yet supported.

See also:


static Future<void> simulateKeyUpEvent(LogicalKeyboardKey key, {String platform, PhysicalKeyboardKey physicalKey}) async {
  return TestAsyncUtils.guard<void>(() async {
    platform ??= Platform.operatingSystem;
    assert(_osIsSupported(platform), 'Platform $platform not supported for key simulation');

    final Map<String, dynamic> data = getKeyData(key, platform: platform, isDown: false, physicalKey: physicalKey);
    await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage(,
          (ByteData data) {},