如何实现reCAPTCHA? [英] flutter_web how to implement RECAPTCHA?

查看:34
本文介绍了如何实现reCAPTCHA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全搞不懂如何用fltter_web实现reCAPTCHA。

当前可用的插件(https://pub.dev/packages/recaptchav2_pluginhttps://pub.dev/packages/flutter_recaptcha_v2)不支持Web。

推荐答案

以下是测试从文章implementation of Google reCAPTCHA v3 in Flutter Web中提取的g_recaptcha_v3包的主要步骤。

  1. 通过Google reCAPTCHA Admin Console注册您的站点。

  1. 添加所需的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
  1. 导航到web文件夹,打开index.html文件,并将以下脚本粘贴到<body>标记中。
<script src="https://www.google.com/recaptcha/api.js?render=recaptcha-site-key"></script>
  1. main方法中添加GRecaptchaV3.ready并运行应用程序。
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await GRecaptchaV3.ready('recaptcha-site-key');
  runApp(const MyApp());
}

这篇关于如何实现reCAPTCHA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆