dropRight method

String dropRight(
  1. int n
)

Drops the last n characters. Returns empty string if n >= length.

Implementation

String dropRight(int n) {
  if (n <= 0) return this;
  if (n >= length) return '';
  return substring(0, length - n);
}