last method

String last(
  1. int len
)

Gets the last len characters of this string, handling Unicode correctly.

Returns the full string if len is greater than the string length.

Implementation

String last(int len) {
  if (isEmpty || len <= 0) return '';
  if (len >= runes.length) return this;
  final List<int> runeList = runes.toList().sublist(runes.length - len);
  return String.fromCharCodes(runeList);
}