beforeFirst method

String beforeFirst(
  1. String string
)

Get the substring of a string before the first occurrence of a string.

Implementation

String beforeFirst(String string) {
  if (this == null) {
    throw ArgumentError('string: $this');
  }
  if (this!.isEmpty) {
    return '';
  }
  final index = this!.indexOf(string);
  if (index == -1) {
    return '';
  }
  return this!.substring(0, index);
}