搜尋套件、儲存庫與 APP 分類

flutter_pin_code_fields 封面
套件詳情v2.2.0

flutter_pin_code_fields

一個 Flutter 套件,可協助您產生可自訂的驗證碼欄位。可用於登入密碼或 OTP。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2490
喜歡數
28
Pub 分數
150

安裝套件

flutter pub add flutter_pin_code_fields

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個可自定義的 Flutter 套件,用於建立驗證碼輸入欄位,非常適合登入密碼或 OTP 輸入。它提供乾淨、可重複使用的介面,支援各種樣式選項與輸入驗證。此套件相容於所有主要平台,包含 Android、iOS、Web、macOS、Windows 與 Linux。設計簡單且彈性,讓開發者能輕鬆將安全且使用者友善的 PIN 碼輸入體驗整合至其應用程式中。

適用情境

  • OTP 驗證流程
  • 使用者以PIN碼登入
  • 安全的身份驗證介面
  • 需要數字代碼的表單輸入
  • 多步驟註冊流程

主要特色

  • 可自訂欄位外觀
  • 支援不同的輸入類型
  • 內建驗證
  • 跨平台相容性
  • 與表單控制器輕鬆整合
  • 適用於所有裝置的響應式設計

適合對象

  • 開發驗證功能的開發者
  • 需要安全PIN碼輸入的應用程式
  • 需要 OTP 輸入欄位的專案
  • 包含數值輸入的介面密集型表單
  • 移動和網頁應用的統一使用者體驗

使用建議

  • 需要手動處理提交邏輯
  • 有限的內建錯誤回饋
  • 無原生生物識別回退支援
  • 可能需要為複雜主題添加額外的樣式
  • 未針對超過6-8位數的長PIN進行優化

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter Pin Code Fields

GitHub workflow status Version GitHub license

A Flutter package to generate customizable pin code fields.

⭐️ to show support!

Features

  • Highly customizable
  • Responsive
  • Supports animations
  • Supports autofocus
  • Supports autofill
  • Supports obscuring text with custom character

Usage

Add flutter_pin_code_fields as a dependency in your pubspec.yaml file.

# pubspec.yaml

dependencies:
  flutter_pin_code_fields: <latest_version>
import import 'package:flutter_pin_code_fields/flutter_pin_code_fields.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return PinCodeFields(
      onComplete(text) => print(text);
    );
  }
}

Examples

Basic

Complete example at example/lib/basic.dart.

Example - Basic
PinCodeFields(
  onComplete(text) => print(text),
)

Obscuring text

Complete example at example/lib/obscuring_text.dart.

Example - Obscuring text
PinCodeFields(
  length: 6,
  obscureText: true,
  obscureCharacter: "🔴",
  onComplete(text) => print(text),
)

Customized

Complete example at example/lib/customized.dart.

Example - Customized
PinCodeFields(
  length: 4,
  fieldBorderStyle: FieldBorderStyle.square,
  responsive: false,
  fieldHeight: 130.0,
  fieldWidth: 130.0,
  borderWidth: 5.0,
  activeBorderColor: Colors.blue,
  activeBackgroundColor: Colors.white,
  borderRadius: BorderRadius.circular(20.0),
  keyboardType: TextInputType.number,
  inputFormatters: [FilteringTextInputFormatter.digitsOnly],
  autoHideKeyboard: false,
  fieldBackgroundColor: Colors.black12,
  borderColor: Colors.black12,
  textStyle: TextStyle(
    fontSize: 30.0,
    fontWeight: FontWeight.bold,
  ),
  onComplete(text) => print(text),
)

Animated

Complete example at example/lib/animated.dart.

Example - Animated
PinCodeFields(
  obscureText: true,
  obscureCharacter: "❌",
  animation: Animations.rotateRight,
  animationDuration: Duration(milliseconds: 250),
  animationCurve: Curves.bounceInOut,
  switchInAnimationCurve: Curves.bounceIn,
  switchOutAnimationCurve: Curves.bounceOut,
)

Properties

Name Type Default Description
length int 4 Total number of pin code fields.
margin EdgeInsets EdgeInsets.all(5.0) Margin between the fields.
padding EdgeInsets EdgeInsets.only(bottom: 5.0) Padding within the field.
fieldHeight double Height of the field.
fieldWidth double Width of the field.
borderWidth double 2.0 Width of the border of the field.
borderRadius BorderRadius Border raduis of the field.
borderColor Color Colors.grey Border color of the field.
activeBorderColor Color Colors.blue Border color of the active field.
fieldBorderStyle FieldBorderStyle FieldBorderStyle.bottom Border styles of the field.
fieldBackgroundColor Color Colors.transparent Background color of the fields.
activeBackgroundColor Color Colors.transparent Background color of the active field.
enabled bool true Enable/ disable editing the fields.
responsive bool true Adjust the size of the fields automatically to the available space.
autofocus bool false Enable/ disabled autofocus.
textStyle TextStyle Text style for the fields.
obscureText bool false Enable/ disable obscuring the text in the fields.
obscureCharacter String * Character to obscure the text in the fields.
keyboardType TextInputType TextInputType.visiblePassword Keyboard type.
inputFormatters List<TextInputFormatter> Input formatters for the fields.
autoHideKeyboard bool true Hides the keyboard automatically on complete.
animation Animations Animations.fade Animation for the fields.
animationDuration Duration Duration(milliseconds: 150) Duration of the animation.
animationCurve Curve Curves.easeInOut Animation curve.
switchInAnimationCurve Curve Curves.easeIn Switch in animation curve.
switchOutAnimationCurve Curve Curves.easeOut Switch out animation curve.
controller TextEditingController Text editing controller for the fields.
focusNode FocusNode Focus node for the fields.
onChange ValueChanged<String> Callback that returns text on input.
onComplete [required] ValueChanged<String> Callback that returns text on filling all the fields.

所屬分類

原始碼儲存庫

使用此套件的專案