trim function
trim characters (whitespace by default) from both sides of the input
Implementation
String trim(String str, [String? chars]) {
RegExp pattern = (chars != null)
? new RegExp('^[$chars]+|[$chars]+\$')
: new RegExp(r'^\s+|\s+$');
return str.replaceAll(pattern, '');
}