resend_timer_button 1.0.1

SDKflutter
Platformandroidioswindowslinuxmacosweb

A customizable Flutter countdown button used for OTP or resend flows.

resend_timer_button

Pub Version License: MIT Flutter Likes Pub Points Popularity

A customizable Flutter button widget with a built-in countdown timer. Commonly used in OTP, verification, or password reset flows where users need to wait before resending a code or performing an action again.


✨ Features

  • Countdown timer with two formats: mm:ss or raw seconds
  • Three button styles: Elevated, Text, Outlined
  • Custom loading state with optional controller
  • Easy integration with GetX, BLoC, or plain Flutter

🚀 Installation

Add this to your pubspec.yaml:

dependencies:
  resend_timer_button: ^1.0.0

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

  flutter pub get

🔧 Usage

Basic Example

import 'package:resend_timer_button/resend_timer_button.dart';

ResendTimerButton(
onPressed: () {
// trigger resend logic here
},
text: const Text("Resend in"),
duration: 60, // in seconds
)

With Countdown Format

ResendTimerButton(
  onPressed: () => print("Tapped"),
  text: const Text("Resend in"),
  duration: 60,
  format: ResendTimeFormat.time, // or ResendTimeFormat.number
)

With Controller

final controller = ResendTimerButtonController();

ResendTimerButton(
  controller: controller,
  onPressed: () async {
    controller.loading();
    await Future.delayed(Duration(seconds: 2));
    controller.startTimer();
  },
  text: Text("Resend"),
  duration: 120,
)

📱 Demo

Demo


🎨 Parameters

PropertyTypeDescription
onPressedVoidCallback?Called when the button is tapped
textTextText widget to show
durationintCountdown duration in seconds
formatResendTimeFormattime (mm:ss) or number (seconds)
buttonTypeButtonTypeElevated, Text, or Outlined button style
controllerResendTimerButtonController?Optional external controller
loadingIndicatorProgressIndicator?Custom loading indicator
textColorColor?Color of the text
backgroundColorColor?Button background color
loadingIndicatorColorColor?Color of loading spinner
radiusdouble?Border radius
heightdouble?Height of the button

🛠 Maintainer

Maintained by Abdulmajeed Altwaireb
Feel free to open an issue or submit a pull request.


🤝 Contributing

Contributions are welcome and appreciated!
Please open issues for bugs, suggestions, or enhancements.
Pull requests should follow Flutter's style guide.


📄 License

This project is licensed under the MIT License.