sendCommand method

  1. @override
Future<Map<String, dynamic>> sendCommand (
  1. Command command
)
override

Sends command to the Flutter Driver extensions. This must be implemented by subclass.

See also:

Implementation

@override
Future<Map<String, dynamic>> sendCommand(Command command) async {
  Map<String, dynamic> response;
  try {
    final Map<String, String> serialized = command.serialize();
    _logCommunication('>>> $serialized');
    final Future<Map<String, dynamic>> future = _appIsolate.invokeExtension(
      _flutterExtensionMethodName,
      serialized,
    ).then<Map<String, dynamic>>((Object value) => value as Map<String, dynamic>);
    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)
    throw DriverError('Error in Flutter application: ${response['response']}');
  return response['response'] as Map<String, dynamic>;
}