handleExtension static method

  1. @visibleForTesting
Future<ServiceExtensionResponse> handleExtension(
  1. String command,
  2. Map<String, String> parameters
)

Handles a service extension call from Metro.

Implementation

@visibleForTesting
static Future<developer.ServiceExtensionResponse> handleExtension(
  String command,
  Map<String, String> parameters,
) async {
  try {
    final Map<String, dynamic> args = decodeArgs(parameters['args']);
    final Object? result = await dispatch(command, args);
    return developer.ServiceExtensionResponse.result(
      jsonEncode({'result': result}),
    );
  } on LiveException catch (e) {
    return developer.ServiceExtensionResponse.error(e.code, e.message);
  } catch (e) {
    return developer.ServiceExtensionResponse.error(
      developer.ServiceExtensionResponse.extensionError,
      e.toString(),
    );
  }
}