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.

flutter_aliyun_captcha's People

Contributors

lijy91 avatar rebelning avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter_aliyun_captcha's Issues

这也太垃圾了吧,闪退,报错

1599619989632
我的app appkey和scene都填写正确,却提示我错误。这两个都不填就会有结果返回。然后又过不了后端都校验。垃圾东西,检查完毕

弹框背景变黑问题

弹出验证框后把程序切到后台,然后再切回来,透明背景变成黑色问题怎么解决?是webview背景问题引起的! Android真机

关于弹窗展现

有两个问题请教一下~

  1. 展现可以不用弹窗的形式,而是直接嵌入flutter页面里吗?

  2. aliyun更新了调用方式,可以更新一下html么?

debug模式本地虚拟android13上疯狂打印`updateAcquireFence: Did not find frame.`,production模式+android 10正常

Windows 11 Pro 23H2

Flutter 3.19.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7482962148 (2 weeks ago) • 2024-02-27 16:51:22 -0500
Engine • revision 04817c99c9
Tools • Dart 3.3.0 • DevTools 2.31.1
25
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=16.59ms min=12.11ms max=21.35ms count=61
D/EGL_emulation( 5205): app_time_stats: avg=10.94ms min=8.83ms max=13.39ms count=61
36
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=18.16ms min=14.51ms max=33.44ms count=55
24
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=16.65ms min=12.14ms max=20.45ms count=60
D/EGL_emulation( 5205): app_time_stats: avg=10.81ms min=7.99ms max=13.12ms count=60
36
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=19.45ms min=13.80ms max=33.34ms count=52
25
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=16.60ms min=11.65ms max=21.91ms count=61
D/EGL_emulation( 5205): app_time_stats: avg=10.92ms min=8.78ms max=14.48ms count=61
36
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=17.50ms min=14.53ms max=32.80ms count=57
24
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=16.65ms min=10.49ms max=20.68ms count=60
D/EGL_emulation( 5205): app_time_stats: avg=10.52ms min=8.82ms max=13.66ms count=60
36
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=17.47ms min=14.06ms max=34.13ms count=58
25
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=16.61ms min=12.01ms max=21.06ms count=61
D/EGL_emulation( 5205): app_time_stats: avg=10.79ms min=8.98ms max=13.14ms count=61
36
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=19.58ms min=15.20ms max=33.40ms count=51
25
E/FrameEvents( 5205): updateAcquireFence: Did not find frame.
D/EGL_emulation( 5205): app_time_stats: avg=16.59ms min=13.04ms max=20.72ms count=61
D/EGL_emulation( 5205): app_time_stats: avg=10.92ms min=8.68ms max=13.56ms count=61

这个正常吗

偶现滑块UI异常

正常:
image

异常:
image

异常情况下,滑块高度比外层高度小,并且滑动之后背景色没有变绿,请问有遇到过这种情况吗?

iOS有内存泄漏

使用方法正常使用。确定flutter页面已经释放。

FlutterAliyunCaptchaButton, WKWebView都无法释放
通过graph可以看到,FlutterAliyunCaptchaButton存在多个实例

工程Andoid跑不起来

  • What went wrong:
    Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

android 6 滑块不显示

用示例项目试了也不显示,请问有办法能判断滑块是否正常显示吗?想做个降级处理...

20210224163600
20210224163615

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.