recaptchaVerification static method

Future<RecaptchaResult?> recaptchaVerification(
  1. RecaptchaArgs args, {
  2. int? width,
  3. int? height,
})

Implementation

static Future<RecaptchaResult?> recaptchaVerification(
  RecaptchaArgs args, {
  int? width,
  int? height,
}) async {
  _recaptchaVerificationCompleter = Completer<RecaptchaResult?>();
  final server = RecaptchaVerificationServer(args);

  server.onError = (e) {
    _recaptchaVerificationCompleter.completeError(e);
  };

  await server.start();

  final invokeArgs = RecaptchaVerificationInvokeArgs.fromArgs(
    args,
    server.url,
  );

  await _invokeRecaptchaVerification(invokeArgs, width, height);

  return _recaptchaVerificationCompleter.future
      .whenComplete(server.close)
      .timeout(
    const Duration(seconds: 60),
    onTimeout: () {
      server.close();
      return null;
    },
  );
}