搜索分类、插件与代码仓

pin_code_fields 封面
插件详情v10.1.1

pin_code_fields

一个高度可定制的 PIN/OTP 输入字段,支持 Material Design,并具有用于自定义 UI 的无头核心。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
41.5万
喜欢数
2390
Pub 分数
160

安装插件

flutter pub add pin_code_fields

插件介绍

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

一个高度可定制的 Flutter PIN 和 OTP 输入字段,遵循 Material Design 原则设计。支持可视化和无头模式,使开发者能够构建直观的认证界面或完全自定义的 UI。该包提供流畅的动画、实时验证以及跨所有平台的响应式设计。非常适合登录屏幕、验证流程和安全输入表单。

适合场景

  • 通过OTP进行用户身份验证
  • 双因素认证
  • 安全PIN输入
  • 移动应用中的表单验证
  • 可自定义的验证屏幕
  • 跨平台输入字段

主要特点

  • 符合 Material Design
  • 无头模式用于自定义UI
  • 实时输入验证
  • 流畅的动画和过渡
  • 响应式布局支持
  • 可自定义的样式和行为

适合对象

  • 开发安全输入表单的开发者
  • 需要跨平台兼容性的团队
  • 需要 OTP 或 PIN 验证的应用
  • 希望拥有灵活 UI 组件的设计师
  • 需要紧密集成的项目

使用建议

  • 在无头模式下需要手动处理焦点和导航
  • 可能需要额外的逻辑来处理复杂的验证规则
  • 样式自定义需要理解 Flutter 的 widget 树
  • 未针对非常长的输入序列进行优化
  • 内置错误消息有限,仅提供基本反馈

原始 README

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

Pin Code Fields

A highly customizable Flutter package for PIN code and OTP input fields with beautiful design and animations.

Version 9.0 introduces a new headless architecture - use the ready-made Material Design implementation or build completely custom UIs!

Package Location

The publishable package is located at:

packages/pin_code_fields/

📦 View Package README for full documentation.

Quick Start

dependencies:
  pin_code_fields: ^9.0.0
import 'package:pin_code_fields/pin_code_fields.dart';

// Material Design (ready to use)
MaterialPinField(
  length: 6,
  onCompleted: (pin) => print('PIN: $pin'),
)

// Custom UI (headless)
PinInput(
  length: 4,
  builder: (context, cells) => YourCustomUI(cells),
)

Repository Structure

pin_code_fields/
├── packages/
│   └── pin_code_fields/      # 📦 Main package
│       ├── lib/
│       │   └── src/
│       │       ├── core/     # Headless input engine
│       │       └── material/ # Material Design implementation
│       ├── example/
│       ├── test/
│       ├── README.md
│       ├── CHANGELOG.md
│       └── LICENSE
├── docs/
│   └── FEATURE_COMPARISON.md
├── melos.yaml
└── CLAUDE.md

Development

This project uses melos for monorepo management.

# Install melos
dart pub global activate melos

# Bootstrap workspace
melos bootstrap

# Run tests
melos test

# Run analyzer
melos analyze

Features

  • 🎨 Headless Architecture - Full control over UI rendering
  • 📱 Material Design Ready - Beautiful out-of-the-box implementation
  • 🎮 Unified Controller - Single controller for text, focus, and errors
  • ✨ Rich Animations - Scale, fade, slide entry animations
  • 🔐 Obscure Support - Character or custom widget obscuring
  • 📋 Paste Support - Long-press to paste from clipboard
  • 📝 Form Integration - Works with Flutter's Form widget
  • 📲 Autofill Support - SMS OTP autofill for iOS/Android
  • 💫 Error Animation - Shake animation with programmatic control

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE for details.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

所在榜单