substring method Null safety

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

Returns the substring of string between start and end.

Unlike String.substring, end defaults to position rather than the end of the string.

Implementation

String substring(int start, [int? end]) {
  end ??= position;
  return string.substring(start, end);
}