trim function
Removes the given chars from both ends of the string.
If chars is null, leading and trailing whitespace is removed.
Example:
trim(' hello '); // 'hello'
trim('xxhelloxx', 'x'); // 'hello'
Implementation
String trim(String str, [String? chars]) {
return rtrim(ltrim(str, chars), chars);
}