GitHub リポジトリmpcreza/otp_timer_button

otp_timer_button

これは、OTPタイマーボタンを簡単に実装するためのFlutterパッケージです。

otp_timer_button のプロジェクト画像
スター
1
フォーク
3
最終プッシュ(UTC)
2024/02/24
プロジェクト状態
公開中

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

otp_timer_button

This is a Flutter package for easy implementation otp timer button.

Installation

Add the following to your pubspec.yaml file:

dependencies:
    otp_timer_button: ^1.1.1

Usage

Import
import 'package:otp_timer_button/otp_timer_button.dart';
Simple Example
OtpTimerButtonController controller = OtpTimerButtonController();

@override
Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: OtpTimerButton(
          controller: controller,
          onPressed: () {},
          text: Text('Resend OTP'),
          duration: 60,
        ),
      ),
    );
}
Controller

If you want to wait for the response to the OTP request, you can use the controller:

NOTE: if use controller, auto start timer is disabled on pressed button.

  OtpTimerButtonController controller = OtpTimerButtonController();

  _requestOtp() {
    controller.loading();
    Future.delayed(Duration(seconds: 2), () {
      controller.startTimer();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: OtpTimerButton(
          controller: controller,
          onPressed: () => _requestOtp(),
          text: Text('Resend OTP'),
          duration: 2,
        ),
      ),
    );
  }

controller.startTimer();
controller.loading();
controller.enableButton();
All options
OtpTimerButton(
  controller: controller,
  height: 60,
  text: Text(
    'Resend OTP',
  ),
  duration: 60,
  radius: 30,
  backgroundColor: Colors.blue,
  textColor: Colors.white,
  buttonType: ButtonType.text_button, // or ButtonType.outlined_button
  loadingIndicator: CircularProgressIndicator(
    strokeWidth: 2,
    color: Colors.red,
  ),
  loadingIndicatorColor: Colors.red,
  onPressed: () {},
),
reza mohammadzadeh GitHub avatar
GitHub 作者

reza mohammadzadeh ↗

言語C++CMakeDartHTMLSwiftCKotlinObjective-C

カテゴリー

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 2 件

  • flutter{"sdk":"flutter"}
  • flutter_test開発用{"sdk":"flutter"}

プロジェクトに合うリポジトリを選ぶには?

用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。

  1. 名前・作者・説明で検索し、技術トピックで絞り込みます。
  2. スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
  3. 利用前に GitHub で README、ライセンス、Issues を確認します。

情報源と管理

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗