replaceLast method
Replace last String with replacement
string.
If the string is null or empty return default string.
Implementation
String replaceLast(
String substring,
String replacement,
) {
final value = this;
if (value.isNotNullOrEmpty()) {
final int index = value!.lastIndexOf(substring);
if (index == -1) return this!;
return this!.substring(0, index) +
replacement +
this!.substring(index + substring.length);
}
return '';
}