renderSnapshotPreview function
void
renderSnapshotPreview(
- LiveBlock block,
- String device,
- LiveSnapshot snapshot, {
- String export = 'export',
Adds the storage and Backpack tables of snapshot from device to
block, ending with how to save it with export.
Implementation
void renderSnapshotPreview(
LiveBlock block,
String device,
LiveSnapshot snapshot, {
String export = 'export',
}) {
List<List<String>> rows(Map<String, Object?> values) => [
for (final MapEntry<String, Object?> entry in values.entries)
[
entry.key,
LiveSnapshot.describeEntry(entry.value).type,
LiveFormat.value(LiveSnapshot.describeEntry(entry.value).value),
],
];
block.heading(
'Storage on $device (${snapshot.storage.length} '
'${snapshot.storage.length == 1 ? 'value' : 'values'}, '
'${_describeSize(snapshot.sizeInBytes)})',
);
if (snapshot.storage.isEmpty) {
block.note('Storage is empty');
} else {
block.table(['KEY', 'TYPE', 'VALUE'], rows(snapshot.storage));
}
block.plain('');
block.heading(
'Backpack (${snapshot.backpack.length} '
'${snapshot.backpack.length == 1 ? 'value' : 'values'})',
);
if (snapshot.backpack.isEmpty) {
block.note('Backpack is empty');
} else {
block.table(['KEY', 'TYPE', 'VALUE'], rows(snapshot.backpack));
}
renderSnapshotWarnings(block, snapshot);
block.note(
'Save it as a seeder with $export <name>, or as a file with '
'$export --to <path>.json',
);
}