showCaptcha method
Future<String?>
showCaptcha({
- required BuildContext context,
- CaptchaType mode = CaptchaType.dialog,
- required dynamic onError(
- String error
- required dynamic onSuccess(
- String token
Shows the captcha widget in the chosen mode
.
onSuccess
is called when the captcha is solved with a valid token.
onError
is called when captcha fails or closes without solving.
Implementation
Future<String?> showCaptcha({
required BuildContext context,
CaptchaType mode = CaptchaType.dialog,
required Function(String error) onError,
required Function(String token) onSuccess,
}) async {
String? token;
switch (mode) {
case CaptchaType.screen:
token = await _showAsScreen(context);
case CaptchaType.dialog:
token = await _showAsDialog(context);
case CaptchaType.modalBottomSheet:
token = await _showAsBottomSheet(context);
}
if (token != null) {
onSuccess(token);
} else {
onError(onErrorMessage);
}
return token;
}