hb_check_code 0.0.2

Flutter Android iOS web

A graphic captcha generator. You can specify the drawing size, or it can be adaptive according to the length of the string.

开发过程中有遇到这种需求,发现网上案例还比较少,所以决定还是自己撸一个。

支持限制尺寸,也可以根据字符长度自适应。 差不多就是长这样子。 WeChata674f8a31d96e0c460a67aaf7ab94946.png

Installing #

在你的package's pubspec.yaml中加入

dependencies:
  hb_check_code: ^0.0.1

DEMO #

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'HBCheckCode Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: CodeTestPage(),
    );
  }
}

class CodeTestPage extends StatefulWidget {
  @override
  _CodeTestPageState createState() => _CodeTestPageState();
}

class _CodeTestPageState extends State<CodeTestPage> {
  @override
  Widget build(BuildContext context) {
    String code = "";
    for (var i = 0; i < 6; i++) {
      code = code + Random().nextInt(9).toString();
    }
    return Scaffold(
        appBar: AppBar(
          title: Text("生成图形验证码"),
        ),
        body: Container(
            alignment: Alignment.center,
            child: HBCheckCode(
              code: code,
            )));
  }
}
1
likes
100
pub points
32%
popularity

A graphic captcha generator. You can specify the drawing size, or it can be adaptive according to the length of the string.

Homepage

Documentation

API reference

Uploader

412625278@qq.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on hb_check_code