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

套件詳情v0.3.2

flutter_otp

一個用於發送和驗證OTP的Flutter套件。四位數字OTP(可自訂)會以簡訊方式發送到給定的電話號碼(及國家代碼)。

近 30 天下載
111
喜歡數
85
Pub 分數
40

安裝套件

flutter pub add flutter_otp

套件介紹

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

一個用於透過簡訊簡化發送和驗證一次性密碼(OTP)流程的Flutter套件。它支援可自訂的OTP長度,通常為四位數字,並與包含國家代碼的電話號碼整合。該套件透過安全且高效地處理OTP產生、傳遞和驗證,簡化使用者認證流程。適用於需要雙因素認證的登入、註冊或帳戶復原工作流程。

適用情境

  • 用戶登入使用OTP
  • 帳戶驗證
  • 密碼重置
  • 雙因素驗證
  • 安全接入
  • 基於簡訊的驗證

主要特色

  • 可自定義的OTP長度
  • 簡訊整合用於OTP傳遞
  • 支援國家代碼
  • OTP 驗證的簡單 API
  • 安全的OTP處理
  • 輕鬆設定,設定最少

適合對象

  • 需要OTP驗證的移動應用
  • 認證系統
  • 用戶註冊流程
  • 注重安全的應用程式
  • 使用簡訊雙因素認證的應用程式
  • 尋求快速OTP實現的開發者

使用建議

  • 依賴外部簡訊服務
  • 僅限簡訊傳送方式
  • 無內建的一次性密碼過期管理
  • 需要對失敗的投遞進行適當的錯誤處理
  • 依賴第三方簡訊服務提供者的可靠性
  • 不適用於離線使用

原始 README

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

Awesome Flutter contributions welcome Known Vulnerabilities Build Status

flutter_otp

A Flutter package for Android and iOS for sending and verifying OTP to a Phone number.

Important message for existing Users
NEW FEATURE !!

Now you can send the message to any country code passed as a parameter to the interface (sendOtp() function)

Installing

Use this package as a library

1. Depend on it

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

dependencies:
  flutter_otp: ^0.3.2
2. Install it

You can install packages from the command line: with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_otp/flutter_otp.dart';

Functions

The important functions used in the package are :

  1. sendOtp() to send a OTP (four digit by default, but customizable):
void sendOtp(String phoneNumber, [String messageText]) {
    ...        
}

NOTE:

  1. 10 digit phoneNumber should be passed.
  2. parameter "messageText" is optional. By default the message text is "Your OTP is : XXXX". If "messageText" parameter is passed then message is sent as " XXXX".
  1. resultChecker() which takes the OTP entered by the user as a parameter. The function returns true if OTP is matched, else false is returned.
bool resultChecker(int enteredOtp) {
    ...
} 

NOTE: The OTP entered by user (say, through TextField widget or TextFormField widget etc) is to be passed as a parameter to this function.

Usage

To use this package in your application you need to have a sim card in your mobile.

Example Usage:

...
sendOtp('958347XXXX');  //Pass phone number as String

...

int enteredOtp;
TextField(
  onChanged: (val) {
    enteredOtp = val;    
  }
)

...

bool isCorrectOTP = resultChecker();
if(isCorrectOTP) {
    print('Success');
} else {
    print('Failure');
}
...

OR custom "messageText" can be passed as parameter to sendOTP

...
sendOtp('958347XXXX', 'OTP is : ');  //Pass phone number and Custom messaseText as String

...

int enteredOtp;
TextField(
  onChanged: (val) {
    enteredOtp = val;    
  }
)

...

bool isCorrectOTP = resultChecker();
if(isCorrectOTP) {
    print('Success');
} else {
    print('Failure');
}
...

Contributors

  1. Fawaz Hussain
  2. Jerin Francis

:star: the repo to show support!

More Information

Pub package Flutter documentation.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。