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.
- Open
pubspec.yamlin your project. - Add
timer_button_forkdependency and replace[version]with the latest version:
dependencies:
flutter:
sdk: flutter
timer_button_fork: ^[version]- Install it by running command:
flutter pub get
import 'package:timer_button_fork/timer_button_fork.dart';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.
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.
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.
