captcha_plugin_flutter 1.1.7 copy "captcha_plugin_flutter: ^1.1.7" to clipboard
captcha_plugin_flutter: ^1.1.7 copied to clipboard

captcha plugin.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';
import 'package:captcha_plugin_flutter/captcha_plugin_flutter.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final CaptchaPluginFlutter captchaPlugin = new CaptchaPluginFlutter();

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

  }

  /**
   * 初始化验证码
   */
  void init() {
    CaptchaPluginConfig styleConfig = CaptchaPluginConfig(
        radius: 10,
        capBarTextColor:"#25D4D0",
        capBarTextSize: 18,
        capBarTextWeight:"bold",
        borderColor:"#25D4D0",
        borderRadius:10,
        backgroundMoving:"#DC143C",
        executeBorderRadius:10,
        executeBackground:"#DC143C",
        capBarTextAlign:"center",
        capPaddingTop:10,
        capPaddingRight:10,
        capPaddingBottom:10,
        capPaddingLeft:10,
        paddingTop:15,
        paddingBottom:15
    );

    captchaPlugin.init({
      "captcha_id": "请输入易盾业务id",
      "is_debug": true,
      "dimAmount": 0.8,
      "is_touch_outside_disappear": true,
      "timeout": 8000,
      "is_hide_close_button": false,
      "use_default_fallback": true,
      "failed_max_retry_count": 4,
      "is_close_button_bottom":true,
      'theme':'light',
      "styleConfig":styleConfig.toJson(),
    });
  }

  /**
   * 弹出验证码
   */
  void showCaptcha() {
    captchaPlugin.showCaptcha(
        onLoaded: () {
          print("================onLoaded==============");
        },
        onSuccess: (dynamic data) {
          print(data);
        },
        onClose: (dynamic data) {
           print(data);
        },
        onError: (dynamic data) {
          print(data);
        });
  }


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: new Column(
              children: [
                TextButton(
                    onPressed: () =>
                    {
                      init()
                    },
                    child: Text("初始化")),
                TextButton(
                    onPressed: () => {
                      showCaptcha()
                    },
                    child: Text("显示验证码")),
              ],
            )),
      ),
    );
  }
}
7
likes
100
pub points
81%
popularity

Publisher

unverified uploader

captcha plugin.

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter

More

Packages that depend on captcha_plugin_flutter