betweenFirst method
Get the substring of a string between the first occurrence of two strings.
Implementation
String betweenFirst(String start, String end) {
if (this == null) {
throw ArgumentError('string: $this');
}
if (this!.isEmpty) {
return '';
}
final startIndex = this!.indexOf(start);
if (startIndex == -1) {
return '';
}
final endIndex = this!.indexOf(end, startIndex + start.length);
if (endIndex == -1) {
return '';
}
return this!.substring(startIndex + start.length, endIndex);
}