dropLast method
Returns a new string with the last character removed.
Returns an empty string if the string is empty.
Example:
String name = 'Hello';
name = name.dropLast(); // 'Hell'
Implementation
String dropLast() {
if (isEmpty) return this;
return length > 1 ? substring(0, length - 1) : '';
}