overflow: TextOverflow.ellipsis, 缺陷:会将长字母、数字串整体显示省略
现象:分组-12333333333333333333333333,可能会显示成:分组-1...
解决办法:将每个字符串之间插入零宽空格 String breakWord(String word){ if(word == null || word.isEmpty){ return word; } String breakWord = ' '; word.runes.forEach((element){ breakWord += String.fromCharCode(element); breakWord +='\u200B'; }); return breakWord; }
child: Text( breakWord(text), style: TextStyle( fontSize: 14, color: selected ? TriColor.PRIMARY : TriColor.BLACK), maxLines: 1, overflow: TextOverflow.ellipsis, ),