Skip to main content

material_async_button 5.0.1 copy "material_async_button: ^5.0.1" to clipboard
material_async_button: ^5.0.1 copied to clipboard

Drop-in loading state for Elevated, Filled, Outlined, Text, Icon and FloatingAction Material buttons — spinner while onPressed runs, AsyncButtonTheme, AsyncButtonController.

material_async_button #

pub package pub points CI license: MIT

Drop-in async versions of Flutter's Material buttons. Pass an async callback to onPressed and the button shows a spinner until its Future completes — with double-tap protection, mounted safety, and zero boilerplate state.

material_async_button demo

Quick start #

flutter pub add material_async_button material_ui
import 'package:material_async_button/material_async_button.dart';
import 'package:material_ui/material_ui.dart';

Widget saveButton(Future<void> Function() save) {
  return ElevatedAsyncButton(
    onPressed: save, // shows a spinner until save() completes
    child: const Text('Save'),
  );
}

Note: Since version 4, the buttons target package:material_ui/material_ui.dart. Depend on material_ui and import it (migrate with dart fix --apply --code=migrate_design_widgets); with package:flutter/material.dart, the buttons ignore your ThemeData.

Drop-in buttons #

Material Async counterpart Variants
ElevatedButton ElevatedAsyncButton .icon
FilledButton FilledAsyncButton .tonal, .icon, .tonalIcon
OutlinedButton OutlinedAsyncButton .icon
TextButton TextAsyncButton .icon
IconButton IconAsyncButton .filled, .filledTonal, .outlined
FloatingActionButton FloatingActionAsyncButton .small, .large, .extended

Every Material parameter (style, focusNode, autofocus, clipBehavior, statesController, etc.) is forwarded verbatim.

Common options #

  • Keep width: pass maintainSize: true so the button keeps its idle width while loading.
  • Animate the swap: pass transitionBuilder (e.g. AnimatedSize + AnimatedSwitcher).
  • Configure once: register AsyncButtonTheme in ThemeData.extensions to set defaults app-wide.
  • Trigger from outside: pass an AsyncButtonController (e.g. to submit from a TextField's keyboard "Done" button).

Guides #

  • Theming and animations — AsyncButtonTheme, maintainSize, minLoadingDuration, disableWhileLoading, transitionBuilder, and AsyncButtonSpinner.
  • Controller and custom buttons — AsyncButtonController (trigger, reset, canTrigger) and the low-level AsyncButton escape hatch.
  • Behavior and errors — loading vs disabled state, error handling, and .icon / FAB details.

Agent skill #

This package ships an agent skill in skills/material-async-button-usage/. Install it into your project's agent config with:

dart run skills@ get --package material_async_button --all

Contributing #

See CONTRIBUTING.md.

License #

MIT — see LICENSE.

1
likes
160
points
88
downloads

Documentation

API reference

Publisher

verified publishermehmetesen.com

Weekly Downloads

Drop-in loading state for Elevated, Filled, Outlined, Text, Icon and FloatingAction Material buttons — spinner while onPressed runs, AsyncButtonTheme, AsyncButtonController.

Repository (GitHub)
View/report issues
Contributing

Topics

#button #loading #async #material #widget

License

MIT (license)

Dependencies

flutter, material_ui

More

Packages that depend on material_async_button