Coder Social home page Coder Social logo

leanflutter / flutter_aliyun_captcha Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 9.0 508 KB

适用于 Flutter 的阿里云滑动验证插件

Home Page: https://pub.dev/packages/flutter_aliyun_captcha

License: MIT License

Java 27.72% HTML 6.71% Ruby 4.17% Objective-C 24.62% Dart 36.78%
flutter captcha aliyun aliyun-captcha

flutter_aliyun_captcha's Introduction

flutter_aliyun_captcha

适用于 Flutter 的阿里云人机验证插件

支持滑动验证、智能验证(智能验证暂不支持刮刮卡等形式)。

pub version

屏幕截图

快速开始

安装

将此添加到包的 pubspec.yaml 文件中:

dependencies:
  flutter_aliyun_captcha: ^1.0.5

您可以从命令行安装软件包:

$ flutter packages get

用法

导入 flutter_aliyun_captcha

import 'package:flutter_aliyun_captcha/flutter_aliyun_captcha.dart';

滑动验证

AliyunCaptchaButton 会根据其上层小部件的尺寸自适应,务必在上层小部件设置宽度和高度。

Container(
  width: double.infinity,
  height: 48,
  margin: EdgeInsets.only(
    top: 10,
    bottom: 10,
    left: 16,
    right: 16,
  ),
  child: AliyunCaptchaButton(
    controller: _captchaController,
    type: AliyunCaptchaType.slide, // 重要:请设置正确的类型
    option: AliyunCaptchaOption(
      appKey: '<appKey>',
      scene: 'scene',
      language: 'cn',
      // 更多参数请参见:https://help.aliyun.com/document_detail/193141.html
    ),
    customStyle: '''
      .nc_scale {
        background: #eeeeee !important;
        /* 默认背景色 */
      }

      .nc_scale div.nc_bg {
        background: #4696ec !important;
        /* 滑过时的背景色 */
      }

      .nc_scale .scale_text2 {
        color: #fff !important;
        /* 滑过时的字体颜色 */
      }

      .errloading {
        border: #ff0000 1px solid !important;
        color: #ef9f06 !important;
      }
    ''',
    onSuccess: (dynamic data) {
      // {"sig": "...", "token": "..."}
      _addLog('onSuccess', data);
    },
    onFailure: (String failCode) {
      _addLog('onFailure', 'failCode: $failCode');
    },
    onError: (String errorCode) {
      _addLog('onError', 'errorCode: $errorCode');
    },
  ),
)

智能验证

AliyunCaptchaButton(
    controller: _captchaController,
    type: AliyunCaptchaType.smart, // 重要:请设置正确的类型
    option: AliyunCaptchaOption(
      appKey: '<appKey>',
      scene: 'scene',
      language: 'cn',
      // 更多参数请参见:https://help.aliyun.com/document_detail/193144.html
    ),
    onSuccess: (dynamic data) {
      // {"sig": "...", "token": "..."}
      _addLog('onSuccess', data);
    },
    onFailure: (String failCode) {
      _addLog('onFailure', 'failCode: $failCode');
    },
    onError: (String errorCode) {
      _addLog('onError', 'errorCode: $errorCode');
    },
  ),
)

获取 SDK 版本

String sdkVersion = await AliyunCaptcha.sdkVersion;

许可证

MIT License

Copyright (c) 2021 LiJianying <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.