Create beautiful Loading and Timer buttons in Flutter

Overview

Argon Buttons (Timer and Loading)

Create beautiful Loading and Timer buttons using Argon Buttons. No need to worry about handling animations or timers as this pakage does all the messy stuff for you.

Getting Started

You basically have two widgets that you can use, ArgonButton and ArgonTimerButton. ArgonButton helps you create beautiful loading animation in your buttons. ArgonTimerButton helps you create timer buttons that you can use to handle stuff like "Resend OTP" => "Wait for 10 sec".

Demo

Argon Timer Button Demo Argon Loader Button Demo

ArgonButton

ArgonButton is basically RaisedButton on steroids. That means that you can use the usual parameters that you use with RaisedButtons with a few extra functionalities.

Example:

ArgonButton(
  height: 50,
  width: 350,
  borderRadius: 5.0,
  color: Color(0xFF7866FE),
  child: Text(
    "Continue",
    style: TextStyle(
        color: Colors.white,
        fontSize: 18,
        fontWeight: FontWeight.w700
	),
  ),
  loader: Container(
    padding: EdgeInsets.all(10),
    child: SpinKitRotatingCircle(
      color: Colors.white,
      // size: loaderWidth ,
    ),
  ),
  onTap: (startLoading, stopLoading, btnState) {
  },
)

This creates a button that animates to a circular loader whenever we want to do a network request or any other task that takes some time to output the response. Here I am using SpinKit for showing the rotating loader inside my button. You can use what ever you like.

We animate the button by using the parameters passed in onTap function. On Tap recieves 3 parameter: startLoading(), stopLoading() and btnState

You can call the startLoading function to change the state of the button to Busy which will animate the button and show the loader. When you call the stopLoading function, the button goes to the norma(Idle) state. In the third parameter btnState you can actually check the current state of the button.

Using onTap:

ArgonButton(
[...]
onTap:(startLoading, stopLoading, btnState){
  if(btnState == ButtonState.Idle){
    startLoading();
    await doNetworkRequest();
    stopLoading();
  }
}
)

Properties

  • roundLoadingShape(Default true) : When set to true, it uses borderRadius to creates a round button while in Busy/Loading state
  • width: Width of the button when in Idle state
  • minWidth: Width of the button when in Busy/Loading state. Default value is equal to height in order to create a completely round loading button
  • borderRadius: Border Radius of the button
  • borderSide : BorderSide in order to give border color and width to the button
  • child: Contents of button when in Idle state
  • loader: Contents of button when in Busy/Loading state
  • onTap: (startLoading, stopLoading, btnState) : Function that is called when you click on the button

ArgonTimerButton

ArgonTimerButton is similar to ArgonButton but it also has the functionality of working as a Timer button. You can not only give it a initialTimer value but also restart the timer with different countdown from the onTap function.

Example:

ArgonTimerButton(
  initialTimer: 10, // Optional
  height: 50,
  width: MediaQuery.of(context).size.width * 0.45,
  minWidth: MediaQuery.of(context).size.width * 0.30,
  color: Color(0xFF7866FE),
  borderRadius: 5.0,
  child: Text(
    "Resend OTP",
    style: TextStyle(
        color: Colors.black,
        fontSize: 18,
        fontWeight: FontWeight.w700
    ),
  ),
  loader: (timeLeft) {
    return Text(
      "Wait | $timeLeft",
      style: TextStyle(
          color: Colors.black,
          fontSize: 18,
          fontWeight: FontWeight.w700
        ),
    );
  },
  onTap: (startTimer, btnState) {
    if (btnState == ButtonState.Idle) {
      startTimer(20);
    }
  },
),

The onTap function recieves a startTimer(int count) function and a btnState variable. You can use the startTimer function and pass in the new countdown value to restart the counter. This could be very useful for Resend OTP button where after every click you want to reset the counter to a new value from the server. The loader in this case is a button that recieves time left from the timer and has to return a widget which will be the child in the button.

Properties

  • initialTimer (Optional): it is a optional value given to start the timer when the widget is build
  • roundLoadingShape(Default true) : When set to true, it uses borderRadius to creates a round button while in Busy/Loading state
  • width: Width of the button when in Idle state
  • minWidth: Width of the button when in Busy/Loading state. Default value is equal to height in order to create a completely round loading button
  • borderRadius: Border Radius of the button
  • borderSide : BorderSide in order to give border color and width to the button
  • child: Contents of button when in Idle state
  • loader: It is a function that recieves the left time as parameter and returns the contents of button when in Busy/Loading state
  • onTap: (startTimer, btnState) : Function that is called when you click on the button

More

  • duration: Duration of the animation
  • curve: Curve of animation
  • reverseCurve: Curve of reverse animation
You might also like...

Progress Dialog widget for flutter projects with ability to customize loading widget, background color and background blur.

Progress Dialog widget for flutter projects with ability to customize loading widget, background color and background blur.

DISCONTINUED Checkout ArsDialog ars_progress_dialog Customizable progress dialog for Flutter applications with smooth animation for background dim col

Apr 15, 2022

RoundedLoadingButton is a Flutter package with a simple implementation of an animated loading button, complete with success and error animations.

RoundedLoadingButton is a Flutter package with a simple implementation of an animated loading button, complete with success and error animations.

rounded_loading_button RoundedLoadingButton is a Flutter package with a simple implementation of an animated loading button, complete with success and

Jan 4, 2023

A basic flutter loading overlay

A basic loading overlay Features Creates a new scope where the user cannot leave until you programmatically pop it. Usage import 'package:flutter/mate

Nov 8, 2021

Flutter overlay loading dialog example

Flutter overlay loading dialog example

flutter_overlay_loading_dialog_example Demo

Mar 24, 2022

A Facebook & Twitter Like Card Loading Shimmer Skeleton Library.

A Facebook & Twitter Like Card Loading Shimmer Skeleton Library.

PKSkeleton A Facebook & Twitter Like Card Loading Shimmer Skeleton Library. The source code is 100% Dart, and everything resides in the /lib folder. S

Nov 26, 2022

Global loading widget, which can be used through simple configuration.

Global loading widget, which can be used through simple configuration.

load Global loading widget, which can be used through simple configuration. Pure flutter library, not use native code. It is similar to OKToast in use

Nov 4, 2022

A highly customizable toggle switch with a loading state.

A highly customizable toggle switch with a loading state.

A highly customizable toggle switch with a loading state.

Dec 30, 2022

Powerful Complete and Beautiful Search Component for Flutter

Powerful Complete and Beautiful Search Component for Flutter

A highly customizable search component to accelerate your development. Overview There are many search or search components for Flutter, however this o

Jul 27, 2022

A sliding up panel widget which can be used to show or hide content, beautiful and simple.

A sliding up panel widget which can be used to show or hide content, beautiful and simple.

flutter_sliding_up_panel A sliding up panel widget which can be used to show or hide content, beautiful and simple. demo Getting Started dependencies:

Dec 12, 2022
Comments
  • Restyle Migrade to flutter 2.0 null safety

    Restyle Migrade to flutter 2.0 null safety

    A duplicate of #17 with additional commits that automatically address incorrect style, created by Restyled.

    Since the original Pull Request was opened as a fork in a contributor's repository, we are unable to create a Pull Request branching from it with only the style fixes.

    The following Restylers made fixes:

    • prettier-yaml

    To incorporate these changes, you can either:

    1. Merge this Pull Request instead of the original, or

    2. Ask your contributor to locally incorporate these commits and push them to the original Pull Request

      Expand for example instructions
      ```console
      git remote add upstream https://github.com/iamyogik/argon_buttons_flutter.git
      git fetch upstream pull/<this PR number>/head
      git merge --ff-only FETCH_HEAD
      git push
      ```
      

    NOTE: As work continues on the original Pull Request, this process will re-run and update (force-push) this Pull Request with updated style fixes as necessary. If the style is fixed manually at any point (i.e. this process finds no fixes to make), this Pull Request will be closed automatically.

    Sorry if this was unexpected. To disable it, see our documentation.

    opened by restyled-io[bot] 5
Donation/Support buttons to allow you to add your favorite support buttons like: Paypal, Ko-fi or Patreon and more.

flutter_donation_buttons Donation/Support buttons to allow you to add your favorite support buttons like: Paypal, Ko-fi or Patreon and more. Getting S

null 6 Dec 10, 2022
Cupertino buttons which are used as radio buttons in order to select one value

Flutter Cupertino Radio Choice Cupertino buttons which are used as radio buttons in order to select one value. Tutorial A complete tutorial how to use

Christoph Rothermel 4 Sep 18, 2022
Custom Flutter widgets that makes Checkbox and Radio Buttons much cleaner and easier.

custom_radio_grouped_button Custom Radio Buttons and Grouped Check Box Button Custom Flutter widgets that makes Checkbox and Radio Buttons much cleane

Ketan Choyal 144 Sep 23, 2022
Customizable Material and Cupertino buttons with progress indicators and more

future_button Customizable Material and Cupertino buttons with progress indicators and more.

Erzhan 33 Oct 13, 2022
Flutter Number Picker is a custom widget designed for choosing an integer or decimal number by using add and minus buttons

Flutter Number Picker is a custom widget designed for choosing an integer or decimal number by using add and minus buttons. Getting Started Head to /p

Vũ Phương 2 Jul 4, 2022
Fancy design of radio buttons in Flutter (package).

A Flutter package for new radio button design. With Elegant Animation. Features Usage TODO: Include short and useful examples for package users. Add l

Aymen Boucheffa 0 Nov 26, 2021
pull_down_button is a rework of Flutter's PopupMenuButton to be styled like Pop-Up & Pull-Down Buttons from iOS 14+ with some additional customisation options.

pull_down_button is a rework of Flutter's PopupMenuButton to be styled like Pop-Up & Pull-Down Buttons from iOS 14+ with some additional customisation options.

ĐmĐrl 18 Dec 30, 2022
A widget for swiping through a deck of cards with gestures or buttons.

swiping_card_deck A widget for swiping through a deck of cards with gestures or buttons. This package was inspired when I was trying to develop a Tind

Justin Hutchins 8 Oct 17, 2022
Create beautiful flutter tags quickly and easily

flutter_tags Create beautiful tags quickly and easily. Installing Add this to your package's pubspec.yaml file: Null-safety version (Beta) MORE INFO d

null 2 Mar 4, 2022
Sliding card is a highly customizable flutter package that will help you create beautiful Cards with a sliding animation effect.

Sliding Card Introduction Sliding card is a highly customizable flutter package that will help you create beautiful Cards with a sliding animation eff

null 21 Nov 4, 2022