提交 98103f2d authored 作者: shixiaochen's avatar shixiaochen

1、增加方法hideName(姓名脱敏);

上级 22180c2f
......@@ -40,4 +40,6 @@
* 修复BaseListWidget展示多个loading问题
* ## 1.2.0
* IterableExt增加扩展函数containsKey(通过比对集合内对象唯一属性,判断是否包含该元素)
* ## 1.2.1
* hideName姓名脱敏
\ No newline at end of file
......@@ -129,4 +129,21 @@ bool isMobile(String? phone) {
RegExp exp = RegExp(r'^1[0-9]{10}');
bool matched = exp.hasMatch(phone!);
return matched;
}
/// 姓名脱敏
String hideName(String? name) {
if (name.isNullOrEmpty()) {
return "";
}
if (name!.length == 1) {
return name;
}
if (name.length == 2) {
return name.replaceRange(0, 1, "*");
}
if (name.length > 2) {
return name.replaceRange(1, name.length - 1, "*");
}
return "";
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论