Create Google reCAPTCHA v3 token for Flutter app. Google reCAPTCHA v3 plugin for Flutter. A Google reCAPTCHA is a free service that protects your website from spam and abuse.
Add flutter_google_recaptcha_v3 as dependency to your pubspec file.
flutter_google_recaptcha_v3:
git:
url: https://github.com/YeMyoAung/flutter_google_recaptcha_v3.git
Update minSdkVersion
in app level build.gradle.
defaultConfig {
applicationId "YOUR_APP_ID"
minSdkVersion 21 //<-- this line
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
First of all you need to import our package.
import 'package:flutter_google_recaptcha_v3/google_recaptcha_v3.dart';
And then you can use easily.
You can create a controller invoking RecaptchaController
.
RecaptchaController
take 2 parameters.First on is apiKey
and second one is optional hostName
.
final RecaptchaController controller = RecaptchaController(
'YOUR_API_KEY',
hostName: 'YOUR_HOST_NAME',
);
getRecaptcha
will take BuildContext
and then give you nullable RecaptchaModel
.
final RecaptchaModel? model = await controller.getRecaptcha(context);