Command palette
A command palette makes actions searchable by name. It helps people reach commands without remembering which menu contains them.
Find a note command
#Open Commands and search for Review. Run Review note to change the note’s status. The Reset note command restores the draft.
components/command-palette/appliance/find_command.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class FindCommand extends StatefulWidget {
const FindCommand({super.key});
@override
State<FindCommand> createState() => _FindCommandState();
}
class _FindCommandState extends State<FindCommand> {
bool reviewed = false;
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
children: [
ApplianceButton(
'Commands',
onPressed: () => showApplianceCommandPalette(
context: context,
commands: [
DesignCommand(
label: 'Review note',
onPressed: () => setState(() => reviewed = true),
),
DesignCommand(
label: 'Reset note',
onPressed: () => setState(() => reviewed = false),
),
],
),
),
const SizedBox(height: 12),
Text(reviewed ? 'Reviewed' : 'Draft'),
],
);
}
Parameters
ApplianceCommandPalette API ↗commands- Searchable action names and callbacks.
hint- Prompt in the search field.
Shared behaviour
- Keyboard and focus. Activate Commands and type a few letters. Use the arrows to highlight a match, Enter to run it, and Escape to return without choosing.
- Screen readers. Inspect the search field, matching command names and focused result. Read the note’s status after the palette closes.
- Direction and type. Try the open palette in RTL at phone width. At 200% text, check both the search field and the matching action.