ResourceRecord.fromJson constructor
ResourceRecord.fromJson(})
Implementation
factory ResourceRecord.fromJson(
Map<String, dynamic> json,
String recordKey, {
Map<String, dynamic>? permissions,
List<dynamic>? actions,
}) {
final id = json[recordKey];
if (id == null) {
throw ArgumentError(
'Record is missing its key `$recordKey`. The server always sends it; '
'check the resource\'s recordKey in the panel schema.',
);
}
return ResourceRecord(
id: id as Object,
attributes: json,
permissions: {
for (final entry in (permissions ?? const {}).entries)
if (entry.value is bool) entry.key: entry.value as bool,
},
actions: [
for (final entry in actions ?? const [])
if (entry is Map<String, dynamic>)
if (RecordAction.fromJson(entry) case final action?) action,
],
);
}