truncate static method

String truncate(
  1. String value, {
  2. int length = 4,
})

Implementation

static String truncate(String value, {int length = 4}) {
  if (value.length <= length) {
    return value;
  }

  return '${value.substring(0, length)}...${value.substring(value.length - length)}';
}