PrismCommandPalette class

A ⌘K-style command palette that can be opened from anywhere.

Fuzzy-searches a flat list of PrismCommands, groups the results, and supports full keyboard navigation (arrows, Enter, Escape, or a numeric quick-pick). On compact windows it opens as a full-screen sheet; on wide windows it appears as a centred panel near the top of the screen.

PrismCommandPalette.show(
  context: context,
  commands: [
    PrismCommand(label: 'New note', icon: Icons.add, onSelect: createNote),
    PrismCommand(label: 'Toggle theme', icon: Icons.dark_mode, onSelect: toggleTheme),
  ],
);
Inheritance

Constructors

PrismCommandPalette({Key? key, required List<PrismCommand> commands, String placeholder = 'Type a command or search…', String emptyMessage = 'No matching commands', ValueChanged<PrismCommand>? onCommandSelected, String initialQuery = '', int maxResults = 50})
Creates a command palette. Prefer show to present it as a route.
const

Properties

commands → List<PrismCommand>
Every command available.
final
emptyMessage → String
Shown when nothing matches.
final
hashCode → int
The hash code for this object.
no setterinherited
initialQuery → String
Pre-fills the query.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxResults → int
Caps how many results are rendered at once.
final
onCommandSelected → ValueChanged<PrismCommand>?
Called with the chosen command, before its PrismCommand.onSelect.
final
placeholder → String
Placeholder text for the search field.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<PrismCommandPalette>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

show({required BuildContext context, required List<PrismCommand> commands, String placeholder = 'Type a command or search…', String? initialQuery}) → Future<PrismCommand?>
Presents the palette as a route and resolves with the chosen command.