stringShorten function

String stringShorten(
  1. String value, {
  2. int prefixLength = 6,
})

Implementation

String stringShorten(String value, {int prefixLength = 6}) {
  if (value.length <= 2 + 2 * prefixLength) {
    return value.toString();
  }

  var tLength = value.length;
  var secStart = value.length - prefixLength;
  var firstPart = value.substring(0, prefixLength);
  var secondPart = value.substring(secStart, tLength);

  return "$firstPart…$secondPart";
}