handleExtension static method
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(),
);
}
}