toHex method Null safety

String toHex(
  1. Iterable<int>? list
)

Implementation

String toHex(Iterable<int>? list) {
  if (list == null) {
    return '(null)';
  }

  final iter = list.map((e) => e.toRadixString(16).padLeft(2, '0')).toList();
  if (iter.length < 35) {
    return iter.join(':');
  }
  final parts = iter.sublist(0, 20)
    ..add('(...)')
    ..addAll(iter.sublist(max(20, iter.length - 10), iter.length));
  return parts.join(':');
}