material_async_button 5.0.1
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 #
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.

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 onmaterial_uiand import it (migrate withdart fix --apply --code=migrate_design_widgets); withpackage:flutter/material.dart, the buttons ignore yourThemeData.
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: trueso the button keeps its idle width while loading. - Animate the swap: pass
transitionBuilder(e.g.AnimatedSize+AnimatedSwitcher). - Configure once: register
AsyncButtonThemeinThemeData.extensionsto set defaults app-wide. - Trigger from outside: pass an
AsyncButtonController(e.g. to submit from aTextField's keyboard "Done" button).
Guides #
- Theming and animations —
AsyncButtonTheme,maintainSize,minLoadingDuration,disableWhileLoading,transitionBuilder, andAsyncButtonSpinner. - Controller and custom buttons —
AsyncButtonController(trigger,reset,canTrigger) and the low-levelAsyncButtonescape 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.