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();
  }
  final tLength = value.length;
  final secStart = value.length - prefixLength;
  final firstPart = value.substring(0, prefixLength);
  final secondPart = value.substring(secStart, tLength);
  return '$firstPart…$secondPart';
}