async_button_build 1.0.1 copy "async_button_build: ^1.0.1" to clipboard
async_button_build: ^1.0.1 copied to clipboard

A button builder widget that handles asynchronous operations, providing a loading state and automatically managing the enabled/disabled state during execution.

async_button #

A button builder widget that handles asynchronous button operations, providing a convenient way to display a loading state while the async task is being performed.

Features #

  • Asynchronous Handling: Run async functions when the button is pressed.
  • Loading State: Automatically disables the button and displays a loading indicator while the task is running.
  • Customizable: Fully customizable button appearance and behavior through a builder function.

Installation #

Add the following line to your pubspec.yaml under dependencies:

dependencies:
  async_button: ^1.0.0

Then run:

flutter pub get

Usage #

AsyncButton allows you to easily handle button press events that involve asynchronous operations (such as network requests). You can customize the button's appearance using the buttonBuilder function.

AsyncButton(
  onPressedAsync: () async {
    await Future.delayed(const Duration(seconds: 2)); // Async operation
  },
  buttonBuilder: (context, onPressed, working) {
    return ElevatedButton(
      onPressed: onPressed,
      child: working 
        ? CircularProgressIndicator() 
        : Text('Submit'),
    );
  },
)
1
likes
150
points
38
downloads

Publisher

unverified uploader

Weekly Downloads

A button builder widget that handles asynchronous operations, providing a loading state and automatically managing the enabled/disabled state during execution.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on async_button_build