substring method Null safety

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

The substring of the string value from start, inclusive, to end, exclusive.

Example:

const string = 'dougsmith';
var result = string.substring(1); // 'ougsmith'
result = string.substring(1, 3); // 'oug'

Both start and end must be non-negative and no greater than length; end, if provided, must be greater than or equal to start.

Implementation

String substring(int start, [int? end]) => _value.substring(start, end);