truncate method

String truncate(
  1. int length
)

Implementation

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