效果图如上。
代码如下,很简单
static getPayCardStr(String code) {
final int length = code.length;
final int replaceLength = length - 4;
final String replacement = List<String>.generate((replaceLength / 4).ceil(), (int _) => '.... ').join('');
return code.replaceRange(0, replaceLength, replacement);
}
使用方式:
Text(Utils.getPayCardStr('6217580100006198303',),
感谢Alex大佬。