previewKeys function

String previewKeys(
  1. Iterable<String> keys, {
  2. int limit = 6,
})

A short, sorted preview of keys for a summary line.

Implementation

String previewKeys(Iterable<String> keys, {int limit = 6}) {
  final sorted = keys.toList()..sort();
  if (sorted.length <= limit) return sorted.join(', ');
  return '${sorted.take(limit).join(', ')}, … (${sorted.length - limit} more)';
}