overflow: TextOverflow.ellipsis, 缺陷:会将长字母、数字串整体显示省略
现象:分组用户1234567890123456789,可能会显示成:分组用户...
解决办法:将每个字符串之间插入零宽空格
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;
}
直接调用
Text(breakWord('用户01234567890123456789'), textAlign: TextAlign.left, maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w600, ),
),