removeLast method
Removes the last n
characters of the String
.
Example
String foo = 'esentis';
String newFoo = foo.removeLast(3); // 'esen';
Implementation
String? removeLast(int n) {
if (this == null) return null;
if (this!.isEmpty) return this;
if (n <= 0) return this;
if (n >= this!.length) return '';
return this!.substring(0, this!.length - n);
}