decode method
Decodes the given EncodedDocumentData into a Dart value.
Implementation
@override
Object? decode(EncodedDocumentData data) {
switch (_resolveDartFormatFlags(data.flags)) {
case _dartFormatUtf8:
return utf8.decode(data.bytes);
case _dartFormatRaw:
return data.bytes;
case _dartFormatJson:
try {
return _jsonUtf8Decoder.decode(data.bytes);
} on FormatException {
// If we encounter a parse error, assume that we need
// to return bytes instead of an object.
return data.bytes;
}
default:
// Default to returning the raw bytes if all else fails.
return data.bytes;
}
}