before method

String before(
  1. String string
)

Get the substring of a string before a string.

Implementation

String before(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);
}