sendVerifyCodeWithUserName method

Future<bool> sendVerifyCodeWithUserName({
  1. required String username,
  2. required String countryCode,
  3. required int type,
})

Sends a verification code to a user's username with the specified country code and type.

Example Usage:

bool result = await sendVerifyCodeWithUserName(username: 'john', countryCode: '+1', type: 2);
print(result); // true or false

Inputs:

  • username (required): a string representing the user's username
  • countryCode (required): a string representing the country code
  • type (required): an integer representing the type of verification code

Flow:

  1. The method checks if the countryCode and username are not empty and if the type is between 1 and 3.
  2. If the assertions pass, the method invokes the sendVerifyCodeWithUserName method on the methodChannel with the provided parameters.
  3. The method waits for the result and returns it.
  4. If an exception occurs during the method invocation, it is logged and false is returned.

Outputs:

  • Returns a boolean value indicating whether the verification code was successfully sent or not.

Implementation

Future<bool> sendVerifyCodeWithUserName(
    {required String username,
    required String countryCode,
    required int type}) async {
  assert(countryCode.isNotEmpty);
  assert(username.isNotEmpty);
  assert(type > 0 && type <= 3);
  try {
    var res =
        await methodChannel.invokeMethod<bool>('sendVerifyCodeWithUserName', {
      'username': username.trim(),
      'country_code': countryCode.trim(),
      'type': type,
    });
    return res!;
  } on PlatformException catch (e) {
    _log(e);
    return false;
  }
}