搜索插件、代码仓与 APP 分类

omjo_captcha 封面
插件详情v0.0.10

omjo_captcha

一个可自定义的基于文本的验证码小部件,包含随机彩色字符和线条。无需后端支持。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
21
喜欢数
2
Pub 分数
160

安装插件

flutter pub add omjo_captcha

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

omjo_captcha 是一个 Flutter 小部件,提供无需后端的可自定义文本 CAPTCHA。它生成随机的彩色字符和装饰性线条,以帮助防止机器人自动提交表单。设计简洁且易于集成,可无缝融入需要用户验证的表单中。该包支持多种平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,适用于跨平台应用。

适合场景

  • 表单垃圾信息防护
  • 登录/注册流程中的用户验证
  • Web和移动应用中的机器人检测
  • 简单的仅前端验证码解决方案
  • 增强面向公众的表单安全性

主要特点

  • 可自定义的角色颜色和样式
  • 随机文本和行模式
  • 无后端依赖
  • 跨平台兼容性
  • 与 Flutter 表单轻松集成
  • 可配置的难度级别

适合对象

  • 需要轻量级验证码的开发者
  • 具有严格隐私要求的项目
  • 仅前端的安全实现
  • 移动和网络应用
  • 需要快速设置验证码的原型或最小可行产品

使用建议

  • 不适用于高安全环境
  • 仅限视觉模式识别
  • 可能需要进行无障碍调整
  • 依赖客户端随机性
  • 不支持音频或图像验证码

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

omjo_captcha

pub package

A customizable, client-side CAPTCHA widget for Flutter with randomized colorful characters and noise lines.
No backend required — perfect for login forms, guestbooks, or simple human verification needs.


Captcha Screenshot


✨ Features

  • 🎨 Randomized colored characters
  • 🔀 Noise/disturbance lines for bot resistance
  • 🔄 Easy CAPTCHA refresh
  • ✅ Custom validation logic
  • 🚫 Works entirely offline (no server needed)

🌐 Live Demo

🧪 Try it directly in your browser (no installation needed):
👉 https://omjocaptcha.netlify.app


📦 Installation

Add this to your pubspec.yaml:

dependencies:
  omjo_captcha: ^0.0.1

Then run:

flutter pub get

🚀 Usage

Here's a simple example:

import 'package:flutter/material.dart';
import 'package:omjo_captcha/omjo_captcha.dart';
import 'dart:math';

class CaptchaPreview extends StatefulWidget {
  const CaptchaPreview({super.key});

  @override
  State<CaptchaPreview> createState() => _CaptchaPreviewState();
}

class _CaptchaPreviewState extends State<CaptchaPreview> {
  late List<CaptchaChar> characters;
  late List<CaptchaLine> lines;

  @override
  void initState() {
    super.initState();
    _generateCaptcha();
  }

  void _generateCaptcha() {
    final random = Random();
    const text = 'A7B2X';

    characters = text.split('').map((char) {
      return CaptchaChar(
        char: char,
        color: _randomColor(random),
        yOffset: 10 + random.nextDouble() * 10,
        rotation: (random.nextDouble() - 0.5) * 0.3,
      );
    }).toList();

    lines = List.generate(5, (_) {
      return CaptchaLine(
        start: Offset(random.nextDouble() * 120, random.nextDouble() * 50),
        end: Offset(random.nextDouble() * 120, random.nextDouble() * 50),
        color: _randomColor(random),
      );
    });

    setState(() {});
  }

  Color _randomColor(Random random) {
    return Color.fromARGB(
      255,
      100 + random.nextInt(156),
      100 + random.nextInt(156),
      100 + random.nextInt(156),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        CustomPaint(
          size: const Size(150, 50),
          painter: CaptchaPainter(characters, lines),
        ),
        const SizedBox(height: 10),
        ElevatedButton(
          onPressed: _generateCaptcha,
          child: const Text('Refresh Captcha'),
        ),
      ],
    );
  }
}

📁 Folder Structure

lib/
├── omjo_captcha.dart
└── src/
    ├── captcha_painter.dart
    ├── models/
    │   ├── captcha_char.dart
    │   └── captcha_line.dart

🧪 Example App

Clone this repo and run the example:

cd example
flutter run

💡 Tips

  • You can wrap this CAPTCHA in a TextFormField widget for login forms.
  • Combine with your auth logic to validate user input against captchaText.

🛠️ Contributing

Contributions are welcome!
If you found a bug or want a new feature, please open an issue or submit a pull request.


Support the Project

If you find this plugin helpful, consider supporting its development:

  • Buy Me a Coffee

Your support is greatly appreciated!


📄 License

MIT © Abu Khoerul Iskandar Ali (Omjo)
See LICENSE for details.


🙌 Credits

Built with 💙 using Flutter.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。