Button
A button runs an action on the current screen. Give it a verb that tells the reader what will happen. Use a link to take someone to another destination.
Save a draft
#Save the draft, then reset the example to try the action again.
components/button/appliance/save_draft.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class SaveDraft extends StatefulWidget {
const SaveDraft({super.key});
@override
State<SaveDraft> createState() => _SaveDraftState();
}
class _SaveDraftState extends State<SaveDraft> {
bool saved = false;
@override
Widget build(BuildContext context) => Wrap(
alignment: WrapAlignment.center,
spacing: 12,
runSpacing: 12,
children: [
ApplianceButton.filled(
saved ? 'Draft saved' : 'Save draft',
onPressed: saved ? null : () => setState(() => saved = true),
),
ApplianceButton(
'Reset',
onPressed: saved ? () => setState(() => saved = false) : null,
),
],
);
}
Parameters
ApplianceButton API ↗label- Legend printed on the key.
onPressed- Runs the action. Pass null to disable it.
icon- Adds a glyph beside the legend.
style- Overrides the key face.
isDestructiveAction- Applies the destructive action treatment.
focusNode- Supplies the FocusNode owned by the caller.
autofocus- Requests keyboard focus when the control first appears.
Shared behaviour
- Keyboard and focus. Tab moves focus to an enabled button. Enter or Space activates it. A disabled action leaves the focus order.
- Screen readers. The button exposes its label, role and enabled state. The visible label changes when the draft is saved.
- Direction and type. The actions follow reading order in RTL. At larger text sizes they can wrap onto separate lines.