Toast or snackbar
A toast confirms a completed action without interrupting the next one. Put information the reader will need later on the page as well.
Confirm a save
#Press Save draft twice. Each confirmation includes its revision number, so you can see whether this look stacks, queues or replaces a message.
components/toast/appliance/confirm_save.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class ConfirmSave extends StatefulWidget {
const ConfirmSave({super.key});
@override
State<ConfirmSave> createState() => _ConfirmSaveState();
}
class _ConfirmSaveState extends State<ConfirmSave> {
int revision = 0;
@override
Widget build(BuildContext context) => ApplianceToaster(
child: Center(
child: Builder(
builder: (context) => ApplianceButton(
'Save draft',
onPressed: () =>
showApplianceToast(context, 'Revision ${++revision} saved'),
),
),
),
);
}
Parameters
showApplianceToast API ↗message- The confirmation shown after a save.
actionLabel- Words for an optional action.
onAction- Handles that action.
duration- How long a confirmation remains visible.
title- Optional heading for the notice.
Shared behaviour
- Keyboard and focus. Activate Save draft from the keyboard and try a second save while the first message is visible.
- Screen readers. Listen for the saved revision. The trigger keeps its name while the message appears and disappears.
- Direction and type. Look at where the messages appear in RTL and whether their words fit at phone width with larger type.