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.

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Captcha Example',
      home: Scaffold(
        appBar: AppBar(title: const Text('Captcha Demo')),
        body: const Center(child: CaptchaPreview()),
      ),
    );
  }
}

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

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

class _CaptchaPreviewState extends State<CaptchaPreview> {
  late CaptchaController controller;

  @override
  void initState() {
    super.initState();
    controller = CaptchaController();
    controller.refreshCaptcha();
  }

  void _refreshCaptcha() {
    setState(() {
      controller.refreshCaptcha();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        CustomPaint(
          size: const Size(150, 50),
          painter: CaptchaPainter(controller.captchaChars, controller.captchaLines),
        ),
        const SizedBox(height: 10),
        ElevatedButton(
          onPressed: _refreshCaptcha,
          child: const Text('Refresh Captcha'),
        ),
      ],
    );
  }
}
1
likes
160
points
37
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