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.
- Native Flutter widget – no WebView required
- Privacy-friendly, CAPTCHA-like verification
- Supports image and audio code challenge with ALTCHA Sentinel (adaptive CAPTCHA)
- Localizations support
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
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');
},
)
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) |
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,
],
...
);
cd example/
flutter run
MIT License