removeSurrounding method
Return the string only if the delimiter exists in both ends, otherwise it will return the current string
Implementation
String? removeSurrounding(String delimiter) {
if (this == null) return null;
final prefix = delimiter;
final suffix = delimiter;
if ((this!.length >= prefix.length + suffix.length) && this!.startsWith(prefix) && this!.endsWith(suffix)) {
return this!.substring(prefix.length, this!.length - suffix.length);
}
return this;
}