unpackAny function
Unpacks a google.protobuf.Any JSON representation.
Extracts the "@type" field and returns the remaining fields as the
message body.
Returns {"typeUrl": String, "message": Map<String, Object?>}.
Throws ArgumentError if the "@type" field is missing.
Implementation
Map<String, Object?> unpackAny(Map<String, Object?> any) {
final typeUrl = any['@type'];
if (typeUrl is! String) {
throw ArgumentError('Any message missing "@type" field');
}
final message = Map<String, Object?>.from(any);
message.remove('@type');
return {'typeUrl': typeUrl, 'message': message};
}