substring function
Returns a substring of value from start to end.
- If
endis-1or greater than the string length, uses the full length. - Returns
nullifvalueisnull.
Implementation
String? substring(String? value, int start, [int end = -1]) {
if (value == null) return null;
final maxEnd = value.length;
return value.substring(start, end > 0 && end <= maxEnd ? end : maxEnd);
}