omjo_captcha 0.0.10 copy "omjo_captcha: ^0.0.10" to clipboard
omjo_captcha: ^0.0.10 copied to clipboard

A customizable text-based CAPTCHA widget for Flutter with randomized colorful characters and lines. No backend required.

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.

1
likes
160
points
53
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable text-based CAPTCHA widget for Flutter with randomized colorful characters and lines. No backend required.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on omjo_captcha