decode method

  1. @override
Object? decode(
  1. EncodedDocumentData data
)
override

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;
  }
}