removePostfixIfPresent method
Remove the postfix of a String if present or return current String.
Implementation
String removePostfixIfPresent(String toRemove) {
if (!endsWith(toRemove)) {
return this;
}
final lastIndex = lastIndexOf(toRemove);
return substring(0, lastIndex);
}