hidePhone static method

String hidePhone(
  1. String phone,
  2. int num
)

Implementation

static String hidePhone(String phone, int num) {
  final int length = phone.length;
  final int replaceLength = length - num;
  final String replacement =
      List<String>.generate((replaceLength / 4).ceil(), (int _) => '***')
          .join('');
  return phone.replaceRange(0, replaceLength, replacement);
}