hcaptcha

Last updated:

0 purchases

hcaptcha Image
hcaptcha Images
Add to Cart

Description:

hcaptcha

Integrate hCaptcha into your Flutter App without any dependency.
Getting started #
Use pub to install package
flutter pub add hcaptcha
copied to clipboard
Now initialize hCaptcha using
HCaptcha.init(initialSite: 'https://YOUR-SITE.com/path-to-captcha.html');
// OR
HCaptcha.init(siteKey: 'YOUR-SITE-KEY');
copied to clipboard
If you use initialSite then provide link to a html file with content
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Captcha Challenge</title>
</head>

<body>
<div style="display: flex; justify-content: center;">
<form method="POST">
<div class="h-captcha" data-sitekey="YOUR_SECRET_GOES_HERE" data-callback="captchaCallback"></div>
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
</form>
</div>

<script>
function captchaCallback(response) {
if (typeof Captcha!=="undefined") {
Captcha.postMessage(response);
}
}
</script>
</body>
</html>
copied to clipboard
Usage #
Inside your form, add the captcha logic when submitting:
if (_formKey.currentState!.validate()) {
Map? captchaDetails = await HCaptcha.show(context);

// validated
if (captchaDetails != null) {
// now use captchaDetails['code']
}
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.