패키지, 저장소 및 앱 카테고리 검색

g_recaptcha_v3 표지
패키지 상세v1.1.0

g_recaptcha_v3

Flutter Web용 Google reCAPTCHA v3 플러그인입니다. Google reCAPTCHA는 웹사이트를 스팸 및 오용으로부터 보호하는 무료 서비스입니다.

Web
30일 다운로드
2.3만
좋아요
61
Pub 점수
140

패키지 설치

flutter pub add g_recaptcha_v3

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

g_recaptcha_v3 패키지는 Google reCAPTCHA v3(스팸 및 오용 보호 서비스)를 웹 애플리케이션에 통합하는 Flutter Web 플러그인입니다. 사용자 상호작용 없이 비활성화된 도전 과제 검증을 가능하게 하여 인간 사용자와 봇을 구분하는 데 도움을 줍니다. 이 플러그인은 클라이언트 측에서 점수를 가져오고 응답을 검증하기 위한 Dart API를 제공하여 구현을 간소화합니다. 웹 플랫폼 전용으로 설계되어 Flutter의 웹 배포와 원활하게 작동합니다.

사용 사례

  • 스팸으로부터 웹 양식 보호
  • 로그인 및 등록 엔드포인트 보호
  • 자동화된 봇 공격 방지
  • API 엔드포인트 보안 강화
  • 의심스러운 사용자 행동 모니터링

주요 기능

  • 비가시적 reCAPTCHA 통합
  • 클라이언트 측 점수 검증
  • 웹 플랫폼 전용
  • 간단한 Dart API
  • 서버 측 검증을 지원합니다
  • 가볍고 빠름

적합한 대상

  • 봇 보호가 필요한 플러터 웹 애플리케이션
  • Google reCAPTCHA v3 통합 개발자
  • 비침습적 CAPTCHA가 필요한 프로젝트
  • 보안 중심의 웹 애플리케이션
  • 인증을 사용하는 프론트엔드 개발자

고려 사항

  • 웹 플랫폼에서만 작동합니다
  • 백엔드 검증이 필요합니다
  • Google reCAPTCHA 사이트 키가 필요합니다
  • 인터넷 연결에 따라 다릅니다
  • 모바일 앱에 적합하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

g_recaptcha_v3

Create Google reCAPTCHA v3 tokens for Flutter web. Google reCAPTCHA is a free service that protects your website from spam and abuse. Supports reCAPTCHA Enterprise, recaptcha.net, and WASM builds.

Pub

Web Demo


Preparation

Step 1
Step 2
  • Add g_recaptcha_v3 to pubspec.yaml
  flutter pub add g_recaptcha_v3
Optional: manual script tag

The plugin injects the reCAPTCHA script automatically — no index.html changes are needed. If you prefer to load it yourself (e.g. for an earlier load), add the script inside the web/index.html <head> tag, before the flutter.js / flutter_bootstrap.js script. The plugin detects the existing tag and will not add a second one.

<head>
  <script src="https://www.google.com/recaptcha/api.js?render=<your Recaptcha v3 site key>"></script>
</head>

Development

1. GRecaptchaV3.ready()

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

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  if(kIsWeb){
    bool ready = await GRecaptchaV3.ready("<your Recaptcha site key>"); //--2
    print("Is Recaptcha ready? $ready");
  }
  runApp(const MyApp());
}
2. 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);
  // send token to server and verify
}
  • String action - used to verify the string in backend. ( action docs )
  • token will be null if,
    • the web setup has any errors (see Error handling for diagnosable exceptions).
    • the method is called from a non-web platform.
  • execute() throws a GRecaptchaNotReadyException if ready() was never called.
3. Advanced options
bool ready = await GRecaptchaV3.ready(
  "<your Recaptcha site key>",
  showBadge: false,        // hide the badge (see warning below)
  useRecaptchaNet: true,   // load script from recaptcha.net instead of google.com
                           // (for regions where google.com is blocked, e.g. China)
  useEnterprise: true,     // use reCAPTCHA Enterprise (grecaptcha.enterprise)
  badgeLanguage: 'fr',     // badge language (hl param)
  scriptNonce: '<nonce>',  // CSP nonce for the injected <script> tag
);

// check readiness anywhere
if (GRecaptchaV3.isReady) { ... }
4. Error handling

By default execute() returns null on failure. For diagnosable errors:

try {
  String? token = await GRecaptchaV3.execute('login', throwOnError: true);
} on GRecaptchaNotReadyException {
  // ready() was not called or did not succeed
} on GRecaptchaExecutionException catch (e) {
  // the underlying grecaptcha.execute() call failed
  print(e.message);
}
5. Show / Hide reCaptcha badge

change the reCaptcha badge visibility

    GRecaptchaV3.showBadge();
    GRecaptchaV3.hideBadge();

Warning!!!

You are allowed to hide the badge as long as you include the reCAPTCHA branding visibly in the user flow.

Sample Image

alternate way

Read more about hiding in reCaptcha docs
Web Port 80 setup
(for localhost only)

If in case recaptcha script gives you error for port other than port :80, you can use the following code to setup the port.

  flutter run -d chrome --web-port 80
FAQ

Q: How to hide reCaptcha until / before Flutter render its UI?

A: https://github.com/bharathraj-e/g_recaptcha_v3/issues/3

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.