substringBefore method

String substringBefore(
  1. String? separator
)

Implementation

String substringBefore(String? separator) {
  if (isEmpty) {
    return this;
  }
  if (separator == null) {
    return this;
  }
  int pos = indexOf(separator);
  if (pos < 0) {
    return this;
  }
  return substring(0, pos);
}