Skip to main content

decode method

*[<Null safety>](https://dart.dev/null-safety)*

Future<DecodedContent> decode (EncodedContent encoded)

override

Use the registered codecs to decode the encoded content.

Implementation

@override
Future<DecodedContent> decode(xmtp.EncodedContent encoded) async {
var codec = _codecFor(encoded.type);
if (codec == null) {
if (encoded.hasFallback()) {
return DecodedContent(contentTypeText, encoded.fallback);
}
throw StateError(
"unable to decode unsupported type ${_key(encoded.type)}");
} else {
return DecodedContent(encoded.type, await codec.decode(encoded));
}
}