renderItems function
Adds a KEY / TYPE / VALUE (/ EXPIRES) table for storage-style items.
Implementation
void renderItems(LiveBlock block, Object? items, {required String empty}) {
if (items is! List || items.isEmpty) {
block.note(empty);
return;
}
final List<Map<String, Object?>> rows = items.map(_map).toList()
..sort((a, b) => '${a['key']}'.compareTo('${b['key']}'));
final bool expires = rows.any((row) => row['expiresAt'] != null);
block.table(
['KEY', 'TYPE', 'VALUE', if (expires) 'EXPIRES'],
[
for (final Map<String, Object?> row in rows)
[
'${row['key']}',
'${row['type'] ?? '-'}',
LiveFormat.value(row['value']),
if (expires) '${row['expiresAt'] ?? ''}',
],
],
);
}