WireCacheRecord.fromBytes constructor

WireCacheRecord.fromBytes(
  1. Uint8List bytes
)

Deserialize from bytes.

Implementation

factory WireCacheRecord.fromBytes(Uint8List bytes) {
  final map = jsonDecode(utf8.decode(bytes)) as Map<String, dynamic>;
  return WireCacheRecord(
    canonicalKey: map['canonicalKey'] as String,
    bodyBytes: base64Decode(map['bodyBytes'] as String),
    statusCode: map['statusCode'] as int,
    headers: Map<String, String>.from(map['headers'] as Map),
    cachedAt: DateTime.parse(map['cachedAt'] as String),
    expiresAt: map['expiresAt'] != null
        ? DateTime.parse(map['expiresAt'] as String)
        : null,
    etag: map['etag'] as String?,
    lastModified: map['lastModified'] as String?,
  );
}