truncate method

String truncate(
  1. int truncateLength, {
  2. String endString = "...",
})

Truncates a string to the provided truncateLength

Implementation

String truncate(int truncateLength, {String endString = "..."}) =>
    truncateLength >= this.length
        ? this
        : this.slice(0,truncateLength - endString.length) +
            endString;