safeEndSubstring method

String safeEndSubstring(
  1. int start, [
  2. int? end
])

Substring with safe end, so if end will be greater than length, it will not throw.

Start is not safe.

Implementation

String safeEndSubstring(int start, [int? end]) {
  return substring(start, end == null ? null : math.min(end, length));
}