replaceLast function
replaceLast.
replace oldVal
with newVal
if input
is ended with oldVal
Implementation
String replaceLast(String input, String oldVal, String newVal) {
String result = input;
if (input.endsWith(oldVal)) {
result = '${input.substring(0, input.length - oldVal.length)}$newVal';
}
return result;
}