パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.0.3

otp_screen

Flutterパッケージで、数行のコードでOTP画面を作成するのを支援します。

30日間ダウンロード
18
いいね数
28
Pub ポイント
30

パッケージをインストール

flutter pub add otp_screen

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

otp_screen パッケージは、最小限のコードで OTP 入力画面を作成するのを簡単にする Flutter ユーティリティです。一時的なパスワードの入力に適したクリーンでカスタマイズ可能なウィジェットを提供し、数値入力とテキスト入力を両方サポートしています。このパッケージはフォーカス管理を自動的に処理し、フィールド間のスムーズな遷移を提供し、認証フローにシームレスに統合されます。OTP エントリを迅速かつ信頼性高く実装したい開発者向けに設計されており、ボイラープレートを減らし、ユーザー体験を向上させます。

用途

  • OTPによるユーザー認証
  • アカウント検証ワークフロー
  • 二要素認証
  • ワンタイムコードでログイン
  • 時間制限付きトークン用の安全なフォーム入力

主な機能

  • コード数を最小限にした設定
  • フィールド間の自動フォーカス処理
  • カスタマイズ可能な入力デザイン
  • 数値入力とテキスト入力を両方サポートしています
  • 組み込みの検証とエラー処理

適している対象

  • ログインまたは検証画面を構築している開発者
  • セキュアなOTP入力を必要とするプロジェクト
  • 2FAまたはSMSベースの認証を使用するアプリ
  • 認証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 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。