truncToLength method

String truncToLength(
  1. int length
)

Truncates the string to the given length.

Implementation

String truncToLength(int length) {
  return (this.length > length ? substring(0, length).trim() : this);
}