replaceLast method

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

Replaces the last occurrence of from with to.

Implementation

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