DocumentVersionInfo.fromJson constructor

DocumentVersionInfo.fromJson(
  1. Map<String, dynamic> json
)

One entry of a HISTORY listing. createdAt is Unix ms; servers before history could be turned on sent RFC 3339, which is read too.

Implementation

factory DocumentVersionInfo.fromJson(Map<String, dynamic> json) {
  final at = json['createdAt'];
  return DocumentVersionInfo(
    versionNumber: (json['versionNumber'] as num).toInt(),
    contentHash: json['contentHash'] as String? ?? '',
    contentType: json['contentType'] as String? ?? '',
    createdAt: at is num
        ? at.toInt()
        : (DateTime.tryParse(at as String? ?? '')?.millisecondsSinceEpoch ?? 0),
    size: (json['size'] as num?)?.toInt() ?? 0,
  );
}