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

套件詳情v0.0.3

otp_screen

一個全新的 Flutter 套件,可幫助開發者僅用幾行程式碼即可建立 OTP 屏幕。

近 30 天下載
18
喜歡數
28
Pub 分數
30

安裝套件

flutter pub add otp_screen

套件介紹

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

otp_screen 套件是一個 Flutter 工具,可使用最少的程式碼簡化 OTP 輸入畫面的建立。它提供一個乾淨、可自訂的元件,用於輸入一次性密碼,支援數字與文字輸入。該套件會自動處理焦點管理,提供欄位之間的順暢過渡,並能無縫整合至驗證流程中。專為尋求快速且可靠的 OTP 輸入實作方式的開發者設計,可減少重複程式碼並提升使用者體驗。

適用情境

  • 使用OTP進行用戶身份驗證
  • 帳戶驗證工作流程
  • 雙因素驗證
  • 使用一次性驗證碼登入
  • 限時令牌的安全表單輸入

主要特色

  • 最少的設定,只需幾行程式碼
  • 欄位之間的自動焦點處理
  • 可客製化的輸入設計
  • 支援數值和文字輸入
  • 內建驗證和錯誤處理

適合對象

  • 開發登入或驗證畫面的開發者
  • 需要安全OTP輸入的專案
  • 使用雙重身份驗證或基於簡訊的身份驗證應用程式
  • 快速原型設計身份驗證UI
  • 移動應用中的時效性代碼輸入

使用建議

  • 僅限OTP特定用途
  • 不支援動態欄位數量的內建支援
  • 需要與後端驗證進行手動整合
  • 不處理OTP重發邏輯
  • 不適合複雜表單場景

原始 README

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

otp_screen

A new Flutter package for both android & iOS which helps developer in creating Otp screen with few lines of code.

Show some :heart: and star the repo to support the project

Screenshots


Usage

Example

To use this package:

    dependencies:
        flutter:
          sdk: flutter
        otp_screen: <latest-version>
How to use

  // logic to validate otp return [null] when success else error [String]
  Future<String> validateOtp(String otp) async {
    await Future.delayed(Duration(milliseconds: 2000));
    if (otp == "1234") {
      return null;
    } else {
      return "The entered Otp is wrong";
    }
  }

  // action to be performed after OTP validation is success
  void moveToNextScreen(context) {
    Navigator.push(context, MaterialPageRoute(
        builder: (context) => SuccessfulOtpScreen()));
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      // initialize the OTP screen by passing validation logic and route callback
      home: OtpScreen(
        otpLength: 4,
        validateOtp: validateOtp,
        routeCallback: moveToNextScreen,
        titleColor: Colors.black,
        themeColor: Colors.black,
      ),
    );
  }
}

The above code opens the simple OTP screen


Customize Options

You can play with different colors and add gradients as background to the screen

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: OtpScreen.withGradientBackground(
          topColor: Color(0xFFcc2b5e),
          bottomColor: Color(0xFF753a88),
          otpLength: 4,
          validateOtp: validateOtp,
          routeCallback: moveToNextScreen,
          themeColor: Colors.white,
          titleColor: Colors.white,
          title: "Phone Number Verification",
          subTitle: "Enter the code sent to \n +919876543210",
          icon: Image.asset(
            'images/phone_logo.png',
            fit: BoxFit.fill,
          ),
      ),

The output of the above code will open below screen.

Created & Maintained By

[Lokesh Chennamchetty] (https://github.com/lokesh-sudhakar)

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。