Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

future_button

customizable material and cupertino buttons with progress indicators and more.

useful if you want to run some background tasks when user presses on the button, and then show the result of the task.

future_button

how to use cupertino buttons

usage is extremely simple – right now 5 types of buttons are supported:

  • cupertinobutton (normal + filled)
  • flatbutton (normal + icon)
  • iconbutton
  • outlinebutton (normal + icon)
  • raisedbutton (normal + icon)

to convert a button to a futurebutton, just add a future prefix and make sure that your onpressed callback is of type future<void> function(), instead of usual void function().

everything that the package does can be customized. below is the list of all parameters:

/// the widget that's used as the progress indicator.
/// you can substitute it with your own progress indicator if necessary.
/// see [defaultmaterialprogressindicatorbuilder] and[defaultcupertinoprogressindicatorbuilder] for more info.
final widgetbuilder progressindicatorbuilder;

/// the location of progress indicator.
/// see [progressindicatorlocation] for more info.
final progressindicatorlocation progressindicatorlocation;

/// whether to show the result of the future.
/// will show [successindicatorbuilder] if future completes without errors.
/// otherwise, will show [failureindicatorbuilder].
final bool showresult;

/// whether to animate the transitions using [animatedswitcher].
/// defaults to [true].
final bool animatetransitions;

/// indicator to show when the future is completed successfully.
/// defaults to [defaultsuccessresultindicatorbuilder].
final widgetbuilder successindicatorbuilder;

/// indicator to show when the future fails.
/// defaults to [defaultfailureresultindicatorbuilder].
final widgetbuilder failureindicatorbuilder;

/// for how long should the result be shown for.
/// default to `duration(seconds: 2)`.
final duration resultindicatorduration;

/// curve that's used to animate the button size.
/// defaults to [curves.easeinout].
final curve animationcurve;

/// duration that's used to animate the button size.
/// defaults to `duration(milliseconds: 150)`.
final duration animationduration;

example for cupertino buttons

futureraisedbutton.icon(
  icon: icon(icons.star),
  label: text('star'),
  onpressed: () async {
    // do some background task
    await future.delayed(duration(seconds: 5));
  },
);

see example project for more details.

getting started with cupertino buttons

depend on it

add this to your package’s pubspec.yaml file:

dependencies:
  future_button: ^0.1.1

install it

you can install packages from the command line:

$ flutter pub get

import it

now in your dart code, you can use:

import 'package:future_button/future_button.dart';

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.