splitGenericParameters function
Implementation
List<String> splitGenericParameters(
String str,
[(String, String) genericSeparators = ('<', '>')]
) {
final (left, right) = genericSeparators;
final tok = <String>[];
String word = '';
int nestedAngleBrackets = 0;
for (int i = 0; i < str.length; i++) {
final char = str[i];
if (char == left) {
nestedAngleBrackets++;
}
if (char == right) {
nestedAngleBrackets--;
}
if (nestedAngleBrackets == 0 && char == ',') {
tok.add(word.trim());
word = '';
continue;
}
word += char;
}
tok.add(word.trim());
return tok;
}