formatFieldValue function
One payload value as text, according to its declared FieldKind.
A kind a renderer does not know falls back to text rather than refusing the row — the vocabulary is allowed to grow without every host being updated first.
Implementation
String formatFieldValue(FieldDescriptor field, Object? value) {
if (value == null) return '—';
switch (field.kind) {
case FieldKind.duration:
return value is num ? formatDuration(value) : '$value';
case FieldKind.bytes:
return value is num ? formatBytes(value) : '$value';
case FieldKind.timestamp:
if (value is! num) return '$value';
return DateTime.fromMillisecondsSinceEpoch(value.toInt())
.toIso8601String();
case FieldKind.json:
case FieldKind.number:
case FieldKind.text:
return '$value';
}
}