between method

String between(
  1. String start,
  2. String end
)

Get the substring of a string between two strings.

Implementation

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