ellipseEnd static method

String ellipseEnd(
  1. String value,
  2. int maxLength, {
  3. String ellipseText = "...",
  4. bool appendEllipse = true,
})

Implementation

static String ellipseEnd(String value, int maxLength, {String ellipseText = "...", bool appendEllipse = true}){
  int endIndex;
  if(value.length >= maxLength){
    endIndex = maxLength;
  }
  else{
    endIndex = value.length;
  }

  var validValue = value.substring(0, endIndex).toString();

  if(appendEllipse){
    return validValue + ellipseText;
  }
  else{
    return validValue;
  }
}