sendVerifyCodeWithUserName method
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 usernamecountryCode
(required): a string representing the country codetype
(required): an integer representing the type of verification code
Flow:
- The method checks if the
countryCode
andusername
are not empty and if thetype
is between 1 and 3. - If the assertions pass, the method invokes the
sendVerifyCodeWithUserName
method on themethodChannel
with the provided parameters. - The method waits for the result and returns it.
- 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;
}
}