enterTextByKey method

Future<Response> enterTextByKey(
  1. String text,
  2. String keyValue
)

Implementation

Future<Response> enterTextByKey(String text, String keyValue) async {
  VM vm = await vmService.getVM();
  IsolateRef? mainIsolate = vm.isolates!.first;

  // First tap the widget
  await vmService.callServiceExtension(
    'ext.flutter.driver',
    isolateId: mainIsolate.id!,
    args: {
      'command': 'tap',
      'finderType': 'ByValueKey',
      'keyValueString': keyValue,
      'keyValueType': 'String',
    },
  );

  // Then enter text
  return await vmService.callServiceExtension(
    'ext.flutter.driver',
    isolateId: mainIsolate.id!,
    args: {
      'command': 'enter_text',
      'text': text,
    },
  );
}