搜索插件、代码仓与 APP 分类

flutter_verification_code_field 封面
插件详情v1.2.2

flutter_verification_code_field

Flutter 验证码输入框。主要用于从授权邮件或短信中输入或粘贴 OTP 代码。

AndroidiOS
近 30 天下载
96
喜欢数
27
Pub 分数
160

安装插件

flutter pub add flutter_verification_code_field

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个用于创建干净、可自定义的验证码输入字段的 Flutter 包,非常适合从电子邮件或短信中输入或粘贴 OTP 代码。它支持字段间的自动焦点管理、粘贴检测以及跨设备的流畅用户体验。设计时注重简洁性和易用性,可无缝集成到需要一次性密码的身份验证流程中。

适合场景

  • 登录时输入OTP
  • 双因素认证
  • 通过电子邮件/短信进行账户验证
  • 无密码登录
  • 6位验证码的表单验证
  • 移动应用入门

主要特点

  • 在代码字段之间自动对焦
  • 从剪贴板粘贴检测
  • 可自定义样式
  • 适用于所有屏幕尺寸的响应式设计
  • 同时支持 Android 和 iOS
  • 与表单控制器轻松集成

适合对象

  • 开发人员构建身份验证流程
  • 需要OTP输入的应用程序
  • 以用户体验为中心的移动应用
  • 项目需要最少设置的代码字段
  • 注重可访问性和可用性的团队

使用建议

  • 需要手动处理验证逻辑
  • 限制为单行数字输入
  • 不支持动态字段数量的内置支持
  • 可能需要为非默认主题添加额外的样式
  • 不适用于多步骤验证工作流

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Flutter Verification Code Field

A flutter package which contains a verification code field with a number of advantages, namely with the ability to customize your own validation pattern, customize the number of OTP fields or their size, as well as the spacing between OTP fields, also supports text insertion or character replacement in any cell.


Platform


Table of contents

Installing

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_verification_code_field: ^1.0.0
2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get
3. Import it

Now in your Dart code, you can use:

import 'package:flutter_verification_code_field/flutter_verification_code_field.dart';

Usage

VerificationCodeField is a Hook Widget that can be used for OTP verification. Include it in your code like:

    VerificationCodeField(
      length: 5,
      onFilled: (value) => print(value),
      size: Size(30, 60),
      spaceBetween: 16,
      matchingPattern: RegExp(r'^\d+$'),
    );

It has many configurable properties, including:

  • length – Number of the OTP Fields
  • size – Size of the single OTP Field
  • spaceBetween – Space between the OTP fields
  • matchingPattern – Pattern for validation

There are also custom callback:

  • onFilled – Callback function that is called when the verification code is filled

Bugs or Requests

If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on GitHub and I'll look into it. Pull request are also welcome.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。