safeSubstring method

String safeSubstring(
  1. String str,
  2. int start, [
  3. int? end
])

Implementation

String safeSubstring(String str, int start, [int? end]) {
  end ??= str.length;
  end = end <= str.length ? end : str.length;
  try {
    return str.substring(start, end);
  } catch (e) {
    throw Exception("$e, string $this");
  }
}