command_palette 0.1.1 copy "command_palette: ^0.1.1" to clipboard
command_palette: ^0.1.1 copied to clipboard

outdated

Flutter implementation of the Command Palette. Can be brought up via a keyboard shortcut.

command_palette #

pub package flutter_tests codecov style: flutter lints License: MIT
A Flutter widget that allows you to bring up a command palette, seen in programs like Visual Studio Code and Slack. Allows you to provide users with a convenient way to perform all sorts of actions related to your app.

Features #

  • Access the command palette via a keyboard shortcut, or programmatically.
  • Define a custom list of actions for the user and define the callbacks for each.
  • Use the default styling or build your own custom list items.
  • Use your own filtering logic
  • Use throughout your entire app, or just in certain sections!
  • Support for keyboardless apps too!

Getting started #

To install run the following command:

flutter pub install command_palette

or add command_palette to your pubspec.yaml

Usage #

Start by placing the Command Palette widget in your widget tree:

import 'package:command_palette/command_palette.dart';

//...
CommandPalette(
  actions: [
    CommandPaletteAction(
      label: "Goto Home Page",
      actionType: CommandPaletteActionType.single,
      onSelect: () {
        // go to home page, or perform some other sorta action
      }
    ),
    CommandPaletteAction(
      label: "Change Theme",
      actionType: CommandPaletteActionType.nested,
      description: "Change the color theme of the app",
      shortcut: ["ctrl", "t"],
      childrenActions: [
        CommandPaletteAction(
          label: "Light",
          actionType: CommandPaletteActionType.single,
          onSelect: () {
            setState(() {
              themeMode = ThemeMode.light;
            });
          },
        ),
        CommandPaletteAction(
          label: "Dark",
          actionType: CommandPaletteActionType.single,
          onSelect: () {
            setState(() {
              themeMode = ThemeMode.dark;
            });
          },
        ),
      ],
    ),
  ],
  child: Text("Use a keyboard shortcut to open the palette up!"),
)
//...

Opening Without a Keyboard #

Want to allow devices that don't have a keyboard to open the palette, just use the handy InheritedWidget!

CommandPalette.of(context).open();

Additional information #

Have a feature request, or some questions? Come on down to the discussions tab.

Find a bug or want to open a pull request? Feel free to do so, any and all contributions are welcome and appreciated!

Note about the version #

While I feel confident that this package is ready to use in a real world app. I'm keeping the version below 1.0.0 for the time being incase there is any major changes I'd like to make before I settle down into something.

17
likes
0
pub points
72%
popularity

Publisher

verified publishertylernorbury.com

Flutter implementation of the Command Palette. Can be brought up via a keyboard shortcut.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, substring_highlight

More

Packages that depend on command_palette