handleExtension static method

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

Dispatches a DevTools service extension call and returns a JSON response.

Exposed for unit testing so every extension endpoint and its serialized JSON schema can be verified without requiring a live VM Service connection.

Implementation

@visibleForTesting
static Future<developer.ServiceExtensionResponse> handleExtension(
  String method,
  Map<String, String> parameters,
) async {
  try {
    final payload = await dispatch(method, parameters);
    return developer.ServiceExtensionResponse.result(jsonEncode(payload));
  } catch (e) {
    return developer.ServiceExtensionResponse.result(
      jsonEncode({'success': false, 'error': e.toString()}),
    );
  }
}