buildPreferenceCsv function

String? buildPreferenceCsv(
  1. NameFunction? name,
  2. SupportedFunction? supported,
  3. int? end, [
  4. int? startAfter = 0,
])

Each of the algorithm name-lists MUST be a comma-separated list of algorithm names. Each supported (allowed) algorithm MUST be listed in order of preference, from most to least. https://tools.ietf.org/html/rfc4253#section-7.1

Implementation

String buildPreferenceCsv(
    NameFunction name, SupportedFunction supported, int end,
    [int startAfter = 0]) {
  String ret = '';
  for (int i = 1 + startAfter; i <= end; i++) {
    if (supported(i)) ret += (ret.isEmpty ? '' : ',') + name(i);
  }
  return ret;
}