replaceLast method

String replaceLast(
  1. String from,
  2. String to
)

Implementation

String replaceLast(String from, String to) {
  final index = lastIndexOf(from);
  if (index == -1) return this;
  return substring(0, index) + to + substring(index + from.length);
}