सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
g_recaptcha_v3 पैकेज एक फ्लटर वेब प्लगइन है जो Google reCAPTCHA v3, जो एक स्पैम और दुरुपयोग सुरक्षा सेवा है, को वेब एप्लिकेशन में एकीकृत करता है। यह उपयोगकर्ता के बिना अंतर्निहित चुनौती सत्यापन की अनुमति देता है, जिससे मानव उपयोगकर्ताओं और बॉट्स के बीच अंतर करने में मदद मिलती है। प्लगइन क्लाइंट साइड पर स्कोर प्राप्त करने और प्रतिक्रिया के लिए वैधता की जांच करने के लिए डार्ट एपीआई प्रदान करके कार्यान्वयन को सरल बनाता है। यह विशेष रूप से वेब प्लेटफॉर्म के लिए डिज़ाइन किया गया है और फ्लटर के वेब डेप्लॉयमेंट के साथ बिना किसी समस्या के काम करता है।
उपयोग
स्पैम से वेब फॉर्म की रक्षा करना
लॉगिन और पंजीकरण एंडपॉइंट्स को सुरक्षित करना
स्वचालित बॉट हमलों को रोकना
API एंडपॉइंट्स के लिए सुरक्षा में सुधार
संदिग्ध उपयोगकर्ता व्यवहार की निगरानी
मुख्य विशेषताएँ
अदृश्य reCAPTCHA एकीकरण
क्लाइंट-साइड स्कोर वैधता
वेब प्लेटफॉर्म के लिए केवल
सरल Dart API
सर्वर-पक्ष जाँच समर्थित
हल्का और तेज़
इनके लिए उपयुक्त
बॉट सुरक्षा की आवश्यकता वाले Flutter वेब एप्लिकेशन
Google reCAPTCHA v3 एकीकरण करने वाले विकासकर्मी
गैर-आक्रामक CAPTCHA की आवश्यकता वाले प्रोजेक्ट
सुरक्षा-केंद्रित वेब एप्लिकेशन
प्रारंभिक विकासकर्ता प्रमाणीकरण के साथ काम कर रहे हैं
विचार योग्य बातें
केवल वेब प्लेटफॉर्म पर काम करता है
पीछे की ओर मान्यता की आवश्यकता है
Google reCAPTCHA साइट की की आवश्यक है
इंटरनेट कनेक्टिविटी पर निर्भर करता है
मोबाइल ऐप्स के लिए उपयुक्त नहीं
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
g_recaptcha_v3
Create Google reCAPTCHA v3 tokens for Flutter web. Google reCAPTCHA is a free service that protects your website from spam and abuse. Supports reCAPTCHA Enterprise, recaptcha.net, and WASM builds.
For development, add localhost as domain in reCaptcha console
Step 2
Add g_recaptcha_v3 to pubspec.yaml
flutter pub add g_recaptcha_v3
Optional: manual script tag
The plugin injects the reCAPTCHA script automatically — no index.html changes are needed. If you prefer to load it yourself (e.g. for an earlier load), add the script inside the web/index.html<head> tag, before the flutter.js / flutter_bootstrap.js script. The plugin detects the existing tag and will not add a second one.
<head><scriptsrc="https://www.google.com/recaptcha/api.js?render=<your Recaptcha v3 site key>"></script></head>
Development
1. GRecaptchaV3.ready()
The ready() method should be called before execute()
The ready() method should be called before execute()
import'package:g_recaptcha_v3/g_recaptcha_v3.dart';
voidgenerateToken() async {
String? token = awaitGRecaptchaV3.execute('<your_action>'); //--3print(token);
// send token to server and verify
}
String action - used to verify the string in backend. ( action docs )
token will be null if,
the web setup has any errors (see Error handling for diagnosable exceptions).
the method is called from a non-web platform.
execute() throws a GRecaptchaNotReadyException if ready() was never called.
3. Advanced options
bool ready = awaitGRecaptchaV3.ready(
"<your Recaptcha site key>",
showBadge: false, // hide the badge (see warning below)
useRecaptchaNet: true, // load script from recaptcha.net instead of google.com// (for regions where google.com is blocked, e.g. China)
useEnterprise: true, // use reCAPTCHA Enterprise (grecaptcha.enterprise)
badgeLanguage: 'fr', // badge language (hl param)
scriptNonce: '<nonce>', // CSP nonce for the injected <script> tag
);
// check readiness anywhereif (GRecaptchaV3.isReady) { ... }
4. Error handling
By default execute() returns null on failure. For diagnosable errors:
try {
String? token = awaitGRecaptchaV3.execute('login', throwOnError: true);
} onGRecaptchaNotReadyException {
// ready() was not called or did not succeed
} onGRecaptchaExecutionExceptioncatch (e) {
// the underlying grecaptcha.execute() call failedprint(e.message);
}