truncate method

String truncate(
  1. int length, {
  2. String ellipsis = '...',
})

Truncate string to specified length with ellipsis

Implementation

String truncate(int length, {String ellipsis = '...'}) {
  if (this.length <= length) return this;
  return '${substring(0, length)}$ellipsis';
}