removeWrappingChar method
Returns a new string with char removed from the beginning and/or end.
When trimFirst is true (default), the string is trimmed before
checking.
Implementation
@useResult
String removeWrappingChar(String char, {bool trimFirst = true}) {
String str = trimFirst ? trim() : this;
if (str.startsWith(char)) {
str = str.substringSafe(char.length);
}
if (str.endsWith(char)) {
str = str.substringSafe(0, str.length - char.length);
}
return str;
}