async_button_handler 0.0.1 copy "async_button_handler: ^0.0.1" to clipboard
async_button_handler: ^0.0.1 copied to clipboard

A Flutter package that provides a customizable button widget to handle asynchronous actions with built-in loading and error state handling.

Async Button Handler #

Async Button Handler is a Flutter package that simplifies handling asynchronous actions triggered by button presses. It manages loading and error states without requiring any additional state management libraries. The package is designed to help you reduce boilerplate code while maintaining a clean UI flow for async actions.

Features #

  • Loading State: Shows a loading indicator while an asynchronous task is in progress.
  • Error Handling: Optionally handles errors and allows custom error callbacks.
  • Customizable UI: Accepts custom widgets for both loading and default states, as well as button styling options.
  • Minimal Setup: Eliminates the need for a state management solution, making it easy to integrate into any Flutter project.

Getting started #

Installation #

Add this package to your pubspec.yaml file:

dependencies:
async_button_handler: ^1.0.0

Usage #

First, import the package into your Dart file:


import 'package:async_button_handler/async_button_handler.dart';

Then, use the AsyncButton widget in your widget tree:

AsyncButtonHandler(
  onPressed: () async {
    // Perform any asynchronous action here, e.g., API call
  },
  loadingChild: CircularProgressIndicator(),
  buttonChild: Text('Submit'),
  onError: (error) {
    // Handle error here, e.g., show a snackBar or dialog
    print("Error: $error");
  },
),
7
likes
0
points
29
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that provides a customizable button widget to handle asynchronous actions with built-in loading and error state handling.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on async_button_handler