Action sheet
An action sheet gathers a few operations on one item. Include a way to dismiss it without making a choice.
Choose a file action
#Open File actions and choose Pin or Unpin. The page shows the result after the sheet closes. Reopen it and cancel to keep the current state.
components/action-sheet/appliance/file_actions.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class FileActions extends StatefulWidget {
const FileActions({super.key});
@override
State<FileActions> createState() => _FileActionsState();
}
class _FileActionsState extends State<FileActions> {
bool pinned = false;
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceButton(
'File actions',
onPressed: () => showApplianceActionSheet(
context: context,
title: 'File actions',
actions: [
ApplianceSheetAction(
'Pin',
onPressed: () => setState(() => pinned = true),
),
ApplianceSheetAction(
'Unpin',
onPressed: () => setState(() => pinned = false),
),
],
),
),
const SizedBox(height: 12),
Text(pinned ? 'Pinned' : 'Unpinned'),
],
);
}
Parameters
showApplianceActionSheet API ↗title- Names the item or set of actions.
actions- Lists the choices in reading order.
message- Optional explanation above the choices.
cancelLabel- Words on the cancel action.
Shared behaviour
- Keyboard and focus. Tab to the opener and press Enter. Move through the choices with Tab and activate one, or dismiss the sheet with Escape.
- Screen readers. The file actions have visible names. After the sheet closes, read the current pin state below the opener.
- Direction and type. Labels follow the page direction and text scale. Check both actions and Cancel at the narrow width.