removeLast method

String removeLast([
  1. int n = 1
])

Removes the last n characters from the String.

Example

String foo = 'esentis';
String newFoo = foo.removeLast(3); // 'esen';

Implementation

String removeLast([int n = 1]) {
  if (isBlank || n <= 0) {
    return blankIfNull;
  }

  if (n >= length) {
    return '';
  }
  return substring(0, length - n);
}