Key.fromJson constructor
Implementation
factory Key.fromJson(Map<String, Object?> json) {
final actionsRaw = json["actions"];
final indexesRaw = json["indexes"];
final expiresAtRaw = json["expiresAt"];
final createdAtRaw = json["createdAt"];
final updatedAtRaw = json["updatedAt"];
return Key(
description: json["description"] as String?,
key: json["key"] as String? ?? "",
uid: json["uid"] as String?,
actions: actionsRaw is Iterable
? List<String>.from(actionsRaw)
: defaultActions,
indexes: indexesRaw is Iterable
? List<String>.from(indexesRaw)
: defaultIndexes,
expiresAt:
expiresAtRaw is String ? DateTime.tryParse(expiresAtRaw) : null,
createdAt: createdAtRaw is String ? DateTime.parse(createdAtRaw) : null,
updatedAt: updatedAtRaw is String ? DateTime.parse(updatedAtRaw) : null,
);
}