如何截断Text小部件中每n个字符之后的字符串



我正在处理一行中的一些大字符串,并希望一个字符串,如

0xaff0a761260a3c6a271738550f0d7669dc6de96b5629ed7398735c61b8c55555

显示为

0xaff0a761260a3c6a27
1738550f0d7669dc6de9
6b5629ed7398735c61b8
c55555

如果可能的话

完整的插件

使用这个方法

String sepText(String text, int n) {
String result = '';
int currentIndex = 0;
while (currentIndex < text.length) {
if (currentIndex % n == 0 && currentIndex != 0) result += 'n';
result += text[currentIndex];
currentIndex++;
}
return result;
}

,使用Text(sepText(myString, n)

最新更新