As a web developer, do you want to:
๐ก๏ธ Secure the website traffic from spam data?
๐งน Detect bots injecting malicious code in web forms?
๐ Integrate a ready-made solution for risk analysis?
This project is a demo tutorial through which you can learn the implementation of Google reCAPTCHA v3 in Flutter Web.
recaptcha_v3_tutorial
โโ lib
โ โโ config
โ โ โโ config.dart // Holds the confidential information.
โ โโ model
โ โ โโ recaptcha_response.dart // Holds the Google reCAPTCHA v3 HTTP Response.
โ โโ page
โ โ โโ demo_page.dart // A Demo Page with a [FlutterLogo],a [NameField] & an [ElevatedButton].
โ โโ service
โ โ โโ recaptcha_service.dart // Holds the Google reCAPTCHA v3 Operations.
โ โโ widget
โ โ โโ info_dialog.dart // Shows an [AlertDialog] to the user.
โ โ โโ name_field.dart // Shows a custom [TextFormField] to the user.
โ โโ main.dart
โโ web
โ โโ index.html
โโ pubspec.lock
โโ pubspec.yaml
โโ README.md
-
Register your site via the Google reCAPTCHA.
-
Copy the reCAPTCHA v3
site
andsecret
keys. -
Navigate to the
web
folder, open theindex.html
file and paste the below script inside the<body>
tag.<body> <script src="https://www.google.com/recaptcha/api.js?render=recaptcha-site-key"></script> <!-- This script installs service_worker.js to provide PWA functionality to application. For more information, see: https://developers.google.com/web/fundamentals/primers/service-workers --> </body>
-
In the
config.dart
file, paste the reCAPTCHAsite
&secret
key./// Holds the 'Site Key' for the `Google reCAPTCHA v3` API. static const String siteKey = 'recaptcha-site-key'; /// Holds the 'Secret Key' for the `Google reCAPTCHA v3` API. static const String secretKey = 'recaptcha-secret-key';
-
Congratulations! You're done, run the app.