A Flutter package that enables seamless integration of Google reCAPTCHA v2 into your app. Version (0.1.0)
Demo
Getting started
Add flutter_easy_recaptcha_v2 under your dependencies in the pubspec.yaml file.
dependencies:
flutter:
sdk: flutter
flutter_easy_recaptcha_v2: any
Import it to your Widget
import 'package:flutter_easy_recaptcha_v2/flutter_easy_recaptcha_v2.dart';
And enjoy adding reCAPTCHA v2 to your without the need for any external web page.
Configuration
🤖 Android: Make sure to add android:usesCleartextTraffic="true"
under android/app/src/main/AndroidManifest.xml
<application
android:usesCleartextTraffic="true"
... >
🍏 IOS: No configuration required
Usage
void _showRecaptchaBottomSheet(BuildContext context) {
showModalBottomSheet(
isDismissible: false,
backgroundColor: Colors.white,
isScrollControlled: true,
context: context,
builder: (BuildContext context) {
return SizedBox(
height: 700,
child: Column(
children: [
Align(
alignment: Alignment.topRight,
child: IconButton(
icon: const Icon(
Icons.close,
weight: 20,
),
onPressed: () => Navigator.pop(context),
),
),
SizedBox(
height: 600,
child: RecaptchaV2(
// Your API Key
apiKey: "Your api key",
onVerifiedSuccessfully: (token) async {
log("Recaptcha token $token");
// It is recommended to verify the token on your server but you can also verify it here.
final bool isTokenVerified = await verifyRecaptchaV2Token(
token: token,
apiSecret: "Your api secret",
);
if (isTokenVerified) {
log("Token verified successfully");
// Implement your logic here
} else {
log("Token verification failed");
// Implement your logic here
}
},
),
),
],
),
);
},
);
}