first method
Returns the first count
characters of the string.
If count
exceeds the string length, it returns the whole string.
If the string is empty or null, it returns an empty string.
Implementation
String first([int count = 1]) {
if (isEmpty || count.isLtOrEt(0)) return '';
return length.isLtOrEt(count) ? this : substring(0, count);
}