CommandItem constructor

const CommandItem({
  1. Key? key,
  2. Widget? leading,
  3. required Widget title,
  4. Widget? trailing,
  5. VoidCallback? onTap,
})

Creates a CommandItem for display in a command palette.

Parameters:

  • title (Widget, required): The main label for this command
  • leading (Widget?, optional): Widget displayed before the title (e.g., icon)
  • trailing (Widget?, optional): Widget displayed after the title (e.g., shortcut)
  • onTap (VoidCallback?, optional): Callback when the item is selected

Example:

CommandItem(
  leading: Icon(Icons.file_copy),
  title: Text('Duplicate'),
  trailing: Text('Ctrl+D'),
  onTap: () => duplicate(),
)

Implementation

const CommandItem({
  super.key,
  this.leading,
  required this.title,
  this.trailing,
  this.onTap,
});