safeSubstring function

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

Implementation

String safeSubstring(String str, int start, int end) {
  final len = str.length;
  if (len > start) {
    final lastIndex = min(len, end);
    return str.substring(start, lastIndex);
  }
  return '';
}