unwrapExtensionResult function
Unwraps the VM service extension response.
Extension responses have the shape: {"result": {"result": "<json string>", "type": "_extensionType"}}
The inner "result" is a JSON-encoded string that needs to be decoded.
Implementation
dynamic unwrapExtensionResult(Map<String, dynamic> response) {
final outer = response['result'] as Map<String, dynamic>?;
if (outer == null) return null;
final inner = outer['result'];
if (inner == null) return null;
if (inner is String) {
try {
return jsonDecode(inner);
} catch (_) {
return inner;
}
}
return inner;
}