GitHub 儲存庫mpcreza/otp_timer_button

otp_timer_button

這是一個用於輕鬆實現OTP計時按鈕的Flutter套件。

otp_timer_button 專案封面
星標
1
分支
3
最近推送(UTC)
2024年2月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 ↗