trimString method
Trim with specific characters.
Specify the character string to be trimmed in chars
.
Implementation
String trimString(String chars) {
final pattern = chars.isNotEmpty
? RegExp("^[$chars]+|[$chars]+\$")
: RegExp(r"^\s+|\s+$");
return replaceAll(pattern, "");
}