generate_test_dc_phone_number static method

String generate_test_dc_phone_number({
  1. String dc = "2",
})

If you wish to emulate an application of a user associated with DC number X, it is sufficient to specify the phone number as 99966XYYYY, where YYYY are random numbers, when registering the user.

A user like this would always get XXXXX as the login confirmation code (the DC number, repeated five times).

Note that the value of X must be in the range of 1-3 because there are only 3 Test DCs.

When the flood limit is reached for any particular test number, just choose another number (changing the YYYY random part).

EXAMPLE:

// 99966XYYYY
String phone_number_dc = (GeneralLibUtils.generate_test_dc_phone_number());

Implementation

static String generate_test_dc_phone_number({
  String dc = "2",
}) {
  if (["2", "3", "1"].contains(dc) == false) {
    dc = "2";
  }
  return "99966${dc}YYYY"
      .replaceAllMapped(RegExp("(y)", caseSensitive: false), (match) {
    return "${Random().nextInt(9)}";
  });
}