dropRight method

String dropRight(
  1. int n
)

Drop last n characters from a string.

Implementation

String dropRight(int n) {
  if (this == null) {
    throw ArgumentError('string: $this');
  }
  if (this!.isEmpty) {
    return '';
  }
  if (n < 0) {
    throw ArgumentError('n: $n');
  }
  if (n > this!.length) {
    return '';
  }
  return this!.substring(0, this!.length - n);
}