Timer Button

Build Status License: MIT

A versatile Flutter package that provides a timer button widget, which becomes enabled after a specified time delay.

Timer Button

Overview

A customizable button widget capable of activation after a designated time interval.

Getting Started

  1. Open your project's pubspec.yaml file.
  2. Add the timer_button package to your dependencies, replacing [version] with the latest version:
dependencies:
  flutter:
    sdk: flutter
  timer_button: ^[version]
  1. Run flutter pub get to fetch the package.

Import the Package

import 'package:timer_button/timer_button.dart';

Usage

To use the Timer Button, follow these steps:

  1. Set the button type. There are six types to choose from:
  • ElevatedButton (buttonType: ButtonType.elevatedButton) - default
  • TextButton (buttonType: ButtonType.textButton)
  • OutlineButton (buttonType: ButtonType.outlineButton)
  • Custom (buttonType: ButtonType.custom)
  1. Specify the button label using label: "Your Label".

  2. Set the timeout duration in seconds with timeOutInSeconds: 20.

  3. Customize the button's color using color: Colors.deepPurple.

  4. Define the disabled color with disabledColor: Colors.red.

Example

Default Timer Button:

                TimerButton(
                  label: "Try Again",
                  timeOutInSeconds: 5,
                  onPressed: () {
                    log("Time for some action!");
                  },
                ),

With TimerButton.builder: You can customize the button's appearance by passing a builder function:

                TimerButton.builder(
                  builder: (context, timeLeft) {
                    return Text(
                      "Custom: $timeLeft",
                      style: const TextStyle(color: Colors.red),
                    );
                  },
                  onPressed: () {
                    log("Time for some action!");
                  },
                  timeOutInSeconds: 5,
                ),

Issues and Source Code

For reporting issues and accessing the source code, visit our GitHub Repository.

Contributing

We welcome contributions in various forms:

  • Proposing new features or enhancements.
  • Reporting and fixing bugs.
  • Engaging in discussions to help make decisions.
  • Improving documentation, as it is essential.
  • Sending Pull Requests is greatly appreciated!

A big thank you to all our contributors! 🙌

Libraries

timer_button