Skip to content

Livnium/timer_button_fork

 
 

Repository files navigation

Timer Button for Flutter

Build License: MIT

Timer Button is a Flutter package that provides an interactive, self-disabling button which re-enables after a specified timeout. With our major 4.0.0 release, we have introduced TimerButton.builder for more customizability.

ezgif-1-f263ff5ef4

Getting Started

  1. Open pubspec.yaml in your project.
  2. Add timer_button_fork dependency and replace [version] with the latest version:
dependencies:
  flutter:
    sdk: flutter
  timer_button_fork: ^[version]
  1. Install it by running command: flutter pub get

Importing the Package

import 'package:timer_button_fork/timer_button_fork.dart';

Usage

Choose from three types of buttons:

  • ElevatedButton: buttonType: ButtonType.ElevatedButton
  • TextButton: buttonType: ButtonType.TextButton
  • OutlinedButton: buttonType: ButtonType.OutlinedButton

Specify the label text: label: "Try Again"

Set the timeout duration in seconds: timeOutInSeconds: 20

Define button colors: color: Colors.deepPurple, disabledColor: Colors.red

Now, you can also customize the appearance and behavior of the button during the timeout period using TimerButton.builder.

Example

Traditional use:

TimerButton(
  label: "Send OTP Again",
  timeOutInSeconds: 20,
  onPressed: () {},
  disabledColor: Colors.red,
  color: Colors.deepPurple,
  disabledTextStyle: TextStyle(fontSize: 20.0),
  activeTextStyle: TextStyle(fontSize: 20.0, color: Colors.white),
)

With TimerButton.builder:

TimerButton.builder(
  timeOutInSeconds: 20,
  timeBuilder: (BuildContext context, int seconds) {
    return Text("$seconds seconds");
  },
  onPressed: () {
    print('Button Pressed!');
  },
)

For issues, bugs, and feature requests, visit our GitHub repository.

Contributing

We'd love to have your contributions! Here's how you can help:

  • Propose new features or enhancements
  • Report bugs
  • Fix open issues
  • Participate in discussions and help in decision making
  • Improve documentation. We can't stress the importance of this enough!

Submit your contributions as pull requests on our GitHub.


Please replace 4.0.0 with your actual package version number.

About

A new Flutter plugin for timer button.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 92.7%
  • Swift 3.8%
  • Shell 1.9%
  • Kotlin 1.2%
  • Objective-C 0.4%