beforeLast method
Get the substring of a string before the last occurrence of a string.
Implementation
String beforeLast(String string) {
if (this == null) {
throw ArgumentError('string: $this');
}
if (this!.isEmpty) {
return '';
}
final index = this!.lastIndexOf(string);
if (index == -1) {
return '';
}
return this!.substring(0, index);
}