sendCommand method Null safety
- Command command
override
Sends command
to the Flutter Driver extensions.
This must be implemented by subclass.
See also:
- VMServiceFlutterDriver, which uses vmservice to implement.
- WebFlutterDriver, which uses webdriver to implement.
Implementation
@override
Future<Map<String, dynamic>> sendCommand(Command command) async {
late Map<String, dynamic> response;
try {
final Map<String, String> serialized = command.serialize();
_logCommunication('>>> $serialized');
final Future<Map<String, dynamic>> future = _serviceClient.callServiceExtension(
_flutterExtensionMethodName,
isolateId: _appIsolate.id,
args: serialized,
).then<Map<String, dynamic>>((vms.Response value) => value.json!);
response = await _warnIfSlow<Map<String, dynamic>>(
future: future,
timeout: command.timeout ?? kUnusuallyLongTimeout,
message: '${command.kind} message is taking a long time to complete...',
);
_logCommunication('<<< $response');
} catch (error, stackTrace) {
throw DriverError(
'Failed to fulfill ${command.runtimeType} due to remote error',
error,
stackTrace,
);
}
if ((response['isError'] as bool?) ?? false) {
throw DriverError('Error in Flutter application: ${response['response']}');
}
return response['response'] as Map<String, dynamic>;
}