wrapper static method

Widget wrapper({
  1. required List<HuxCommandItem> commands,
  2. required Widget child,
  3. String placeholder = 'Type a command or search...',
  4. String emptyText = 'No commands found',
  5. ValueChanged<HuxCommandItem>? onCommandSelected,
  6. VoidCallback? onClose,
})

A simple widget that wraps your app and provides command palette shortcuts

Example:

HuxCommandShortcutWrapper(
  commands: myCommands,
  child: MaterialApp(
    home: MyHomePage(),
  ),
)

Implementation

static Widget wrapper({
  required List<HuxCommandItem> commands,
  required Widget child,
  String placeholder = 'Type a command or search...',
  String emptyText = 'No commands found',
  ValueChanged<HuxCommandItem>? onCommandSelected,
  VoidCallback? onClose,
}) {
  return Builder(
    builder: (context) => KeyboardListener(
      focusNode: FocusNode(),
      onKeyEvent: handleKeyEvent(
        context: context,
        commands: commands,
        placeholder: placeholder,
        emptyText: emptyText,
        onCommandSelected: onCommandSelected,
        onClose: onClose,
      ),
      child: child,
    ),
  );
}