takeAfterLast method

String takeAfterLast(
  1. String search
)

Returns the substring after the last occurrence of search.

Returns an empty string if search is not found.

Example:

'path/to/file.txt'.takeAfterLast('/'); // returns: 'file.txt'

Implementation

String takeAfterLast(String search) {
  int index = lastIndexOf(search);
  return index < 0 ? '' : substring(index + search.length);
}