txtLength function

String txtLength(
  1. String? txt, {
  2. int? length,
  3. dynamic nullTxt = "",
})

设置文字长度

Implementation

String txtLength(String? txt, {int? length, nullTxt = ""}) {
  if (txt == null || txt == "") {
    return nullTxt;
  } else {
    if (length != null && txt.length > length) {
      return "${txt.substring(0, length)}...";
    }
    return txt;
  }
}