split function

List<String> split(
  1. String s,
  2. Pattern delimiter, [
  3. int? limit
])

Splits s using delimiter and limit.

delimiter Pattern to use to split s. limit The maximum elements to return.

Note: Standard Dart split doesn't have limit parameter.

Implementation

List<String> split(String s, Pattern delimiter, [int? limit]) {
  if (delimiter is String) {
    return _split(s, delimiter, limit);
  } else if (delimiter is RegExp) {
    return _splitRegExp(s, delimiter, limit);
  } else {
    throw ArgumentError('Invalid delimiter type: $delimiter');
  }
}