g_recaptcha_v3 0.0.1-beta copy "g_recaptcha_v3: ^0.0.1-beta" to clipboard
g_recaptcha_v3: ^0.0.1-beta copied to clipboard

outdated

Google reCAPTCHA v3 plugin for Flutter

g_recaptch_v3 #

Create Google reCAPTCHA v3 token for Flutter web.

Badges #

Pub

MIT License

Preparation #

Step 1

Step 2

  • Add the script inside the web/index.html <body> tag
  <script src="https://www.google.com/recaptcha/api.js?render=<your Recaptcha site key>"></script>

Step 3

  • Add g_recaptch_v3 to pubspec.yaml
  flutter pub add g_recaptch_v3

Development #

GRecaptchaV3.ready() #

The ready() method should be called before execute()

import 'package:g_recaptcha_v3/g_recaptcha_v3.dart'; //--1

void main() async {
  await GRecaptchaV3.ready("<your Recaptcha site key>"); //--2
  runApp(const MyApp());
}

GRecaptchaV3.execute() #

The ready() method should be called before execute()

import 'package:g_recaptcha_v3/g_recaptcha_v3.dart';

void generateToken() async {
  String? token = await GRecaptchaV3.execute('<your_action>'); //--3
  print(token);
}
  • String action - used to verify the string in backend. ( action docs )
  • token will be null if the,
    • web setup has any errors.
    • method called from other than web platform.

Web Port 80 setup #

(for localhost only)

Other than port :80, recaptcha script will give you error.

  flutter run web --web-port 80

Roadmap #

  • Additional platform support

  • reCaptcha Badge setup

44
likes
0
pub points
94%
popularity

Publisher

unverified uploader

Google reCAPTCHA v3 plugin for Flutter

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, flutter_web_plugins, js

More

Packages that depend on g_recaptcha_v3