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