Skip to content

altcha-org/altcha-flutter

Repository files navigation

ALTCHA Flutter Widget

The AltchaWidget is a CAPTCHA-like Flutter component that provides a secure, privacy-friendly way to verify that a user is human—without annoying them. It uses a cryptographic proof-of-work mechanism combined with an optional code challenge, making it resilient against bots and spam.

ALTCHA is an open-source alternative to traditional CAPTCHA, designed to be fast, accessible, and privacy-respecting.

For more information and documentation, visit altcha.org.

Features

  • Native Flutter widget – no WebView required
  • Privacy-friendly, CAPTCHA-like verification
  • Supports image and audio code challenge with ALTCHA Sentinel (adaptive CAPTCHA)
  • Localizations support

Screenshots

ALTCHA Widget in Light theme. ALTCHA Widget in Light theme with Code Challenge. ALTCHA Widget in Dark theme. ALTCHA Widget in Dark theme with Code Challenge.

Installation

Add the following to your pubspec.yaml:

dependencies:
  altcha_widget:
    git:
      url: https://github.com/altcha-org/altcha-flutter.git

Or, if published on pub.dev:

dependencies:
  altcha_widget: ^1.0.0

Then run:

flutter pub get

Usage

import 'package:altcha_widget/widget.dart';
AltchaWidget(
  challengeUrl: 'https://api.example.com/altcha/challenge',
  debug: true,
  onVerified: (payload) {
    // Send the payload to your backend
    print('Payload: $payload');
  },
)

Parameters

One of the challengeUrl or challengeJson is required. Receive the ALTCHA payload, that you send to the server, via onVerified.

Name Type Description
challengeUrl String? URL to fetch the challenge JSON
challengeJson Map<String, dynamic>? Challenge object provided directly
verifyUrl String? Server endpoint to verify the solution
onFailed ValueChanged<Object>? Called with an exception object on verification failure
onVerified ValueChanged<String>? Called with encoded payload after verification
onServerVerification ValueChanged<AltchaServerVerification>? Called with server verification result
delay int? Optional delay before solving (ms)
debug bool Enable verbose logging
hideLogo bool? Hide the ALTCHA logo
hideFooter bool? Hide the footer text
httpClient http.Client? Custom HTTP client (optional)
httpHeaders Map<String, String>? Custom HTTP headers (optional)

Localization

To support different languages, include AltchaLocalizationsDelegate:

import 'package:altcha_widget/localizations.dart';
return MaterialApp(
  localizationsDelegates: [
    AltchaLocalizationsDelegate(),
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
  ],
  supportedLocales: const [
    Locale('en'),
    Locale('de'),
    Locale('es'),
    Locale('fr'),
    Locale('it'),
    Locale('pt'),
  ],
  ...
);

You can also override or add your own translations using AltchaLocalizationsDelegate(customTranslations):

return MaterialApp(
  localizationsDelegates: [
    AltchaLocalizationsDelegate(
      customTranslations: {
        'en': {
          // Define translations keys here
          'label': 'I am human',
        },
      },
    ),
    GlobalMaterialLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
  ],
  ...
);

Example App

cd example/
flutter run

License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published