ellipsis method

String ellipsis([
  1. int? length
])

字符串中间截取

Implementation

String ellipsis([int? length]) {
  if (isEmpty) return '';
  if (length == null || length < 0 || this.length <= length) return this;
  length = (length / 2).floor() - 3;
  return this.substring(0, length + 1) +
      '...' +
      this.substring(this.length - length - 1);
}