replaceBeforeFirst method
Replace before the first occurrence of a string.
Implementation
String replaceBeforeFirst(String string, String replacement) {
if (this == null) {
throw ArgumentError('string: $this');
}
if (this!.isEmpty) {
return '';
}
final index = this!.indexOf(string);
if (index == -1) {
return this!;
}
return replacement + this!.substring(index);
}