Package selection guidance compiled from public package information, community data, and project usage.
A Flutter package that integrates Cloudflare Turnstile, a free CAPTCHA alternative designed to protect applications from bots while offering a seamless user experience. It replaces traditional CAPTCHAs with a simple, privacy-focused challenge that verifies human users without requiring complex interactions. The package supports multiple platforms including Android, iOS, Web, macOS, and Windows, making it ideal for cross-platform apps seeking robust bot protection. Turnstile uses advanced risk analysis to minimize friction for legitimate users. It's easy to implement with minimal configuration and is suitable for forms, login screens, and any high-traffic entry point vulnerable to abuse.
Use cases
Protecting login forms
Securing form submissions
Preventing bot-driven sign-ups
Enhancing API endpoint security
Reducing spam in comment sections
Key features
Free to use
Low user friction
Privacy-first design
Cross-platform support
Real-time risk analysis
Suitable for
Web and mobile apps
High-traffic websites
User registration systems
API endpoints
Applications targeting global audiences
Considerations
Requires internet connection
Dependent on Cloudflare's infrastructure
Limited customization options
May require backend validation
Not suitable for offline environments
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Flutter Cloudflare Turnstile
Cloudflare turnstile is a free CAPTCHAs Alternative, Turnstile delivers frustration-free, CAPTCHA-free web experiences to website visitors - with just a simple snippet of free code. Moreover, Turnstile stops abuse and confirms visitors are real without the data privacy concerns or awful user experience of CAPTCHAs.
[!WARNING]
This package is unofficial and not endorsed by Cloudflare. Use it at your own discretion.
Installation
flutter pub add cloudflare_turnstile
For Windows platform, please follow the inappwebview windows setup instructions.
Example
Here's a quick example that shows how to add Cloudflare Turnstile widget to your flutter app
For Android and iOS platforms you need to provide the baseUrl parameter with the actual URL of your Turnstile Widget Domains list. baseUrl must be the same as the list of domains when creating a Widget.
Using Turnstile invisible mode
Here's how to use Cloudflare's invisible Turnstile, which automatically solves the challenge in the background
import'package:cloudflare_turnstile/cloudflare_turnstile.dart';
classTurnstileService{
/// Retrieves the CloudFlare Turnstile token using invisible mode.staticFuture<String?> get token async {
// Initialize an instance of invisible Cloudflare Turnstile with your site keyfinal turnstile = CloudflareTurnstile.invisible(
siteKey: '1x00000000000000000000BB', // Replace with your actual site key
);
try {
// Get the Turnstile tokenfinal token = await turnstile.getToken();
return token; // Return the token upon success
} onTurnstileExceptioncatch (e) {
// Handle Turnstile failureprint('Challenge failed: ${e.message}');
} finally {
// Ensure the Turnstile instance is properly disposed of
turnstile.dispose();
}
// Return null if the token couldn't be generatedreturnnull;
}
}
[!WARNING]
It's important to call dispose() on the CloudflareTurnstile instance when you no longer need it. This ensures that resources are properly cleaned up, preventing any potential memory issues.
Contribution
Your contributions are welcome and greatly valued! If you have ideas, suggestions, or improvements, feel free to open an issue or submit a pull request. Every bit of help is appreciated, and your input can make a big difference. Just ensure your contributions fit with the project's goals and guidelines.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.