如何实现reCAPTCHA? [英] flutter_web how to implement RECAPTCHA?
本文介绍了如何实现reCAPTCHA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我完全搞不懂如何用fltter_web实现reCAPTCHA。
当前可用的插件(https://pub.dev/packages/recaptchav2_plugin和https://pub.dev/packages/flutter_recaptcha_v2)不支持Web。
推荐答案
以下是测试从文章implementation of Google reCAPTCHA v3 in Flutter Web中提取的g_recaptcha_v3
包的主要步骤。
- 通过Google reCAPTCHA Admin Console注册您的站点。
- 添加所需的
pubspec
包。
# A composable, Future-based library for making HTTP requests.
http: ^0.13.4
# A Google reCAPTCHA is a free service that protects your website from spam and abuse.
g_recaptcha_v3: ^0.0.4
- 导航到
web
文件夹,打开index.html
文件,并将以下脚本粘贴到<body>
标记中。
<script src="https://www.google.com/recaptcha/api.js?render=recaptcha-site-key"></script>
- 在
main
方法中添加GRecaptchaV3.ready
并运行应用程序。
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await GRecaptchaV3.ready('recaptcha-site-key');
runApp(const MyApp());
}
这篇关于如何实现reCAPTCHA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文