unpackFrom<T extends ProtoMessage, S> method
T
unpackFrom<T extends ProtoMessage, S>(
- T decoder(
- S
Deserialize a message from this Any object.
For most message types, you should pass the <type>.fromJson constructor
into this method. Eg.:
if (any.isType(Status.fullyQualifiedName)) {
final status = any.unpackFrom(Status.fromJson);
...
}
Implementation
T unpackFrom<T extends ProtoMessage, S>(T Function(S) decoder) {
final name = typeName;
if (_customEncodedTypes.contains(name)) {
// Handle custom types:
// { "@type": "type.googl...obuf.Duration", "value": "1.212s" }
return decoder(json['value'] as S);
} else {
return decoder(json as S);
}
}