removeLast method

String removeLast(
  1. int n
)

Returns the string with the last n characters removed.

Example:

'hello'.removeLast(2); // 'hel'

Implementation

String removeLast(int n) {
  assert(n >= 0, 'n must be non-negative');
  return n >= length ? '' : substring(0, length - n);
}