call method Null safety
visibleForTesting">@visibleForTesting
Processes a driver command configured by params
and returns a result
as an arbitrary JSON object.
params
must contain key "command" whose value is a string that
identifies the kind of the command and its corresponding
CommandDeserializerCallback. Other keys and values are specific to the
concrete implementation of Command and CommandDeserializerCallback.
The returned JSON is command specific. Generally the caller deserializes the result into a subclass of Result, but that's not strictly required.
Implementation
@visibleForTesting
Future<Map<String, dynamic>> call(Map<String, String> params) async {
final String commandKind = params['command']!;
try {
final Command command = deserializeCommand(params, this);
assert(WidgetsBinding.instance.isRootWidgetAttached || !command.requiresRootWidgetAttached,
'No root widget is attached; have you remembered to call runApp()?');
Future<Result> responseFuture = handleCommand(command, _prober, this);
if (command.timeout != null) {
responseFuture = responseFuture.timeout(command.timeout!);
}
final Result response = await responseFuture;
return _makeResponse(response.toJson());
} on TimeoutException catch (error, stackTrace) {
final String message = 'Timeout while executing $commandKind: $error\n$stackTrace';
_log(message);
return _makeResponse(message, isError: true);
} catch (error, stackTrace) {
final String message = 'Uncaught extension error while executing $commandKind: $error\n$stackTrace';
if (!_silenceErrors) {
_log(message);
}
return _makeResponse(message, isError: true);
}
}