unwrap static method
Strips a single instance of before from the start and after
(or before if after is null) from the end of value.
Implementation
static String unwrap(String value, String before, [String? after]) {
final end = after ?? before;
var result = value;
if (before.isNotEmpty && result.startsWith(before)) {
result = result.substring(before.length);
}
if (end.isNotEmpty && result.endsWith(end)) {
result = result.substring(0, result.length - end.length);
}
return result;
}