@@ -85,6 +85,10 @@ class CommandPaletteController extends ChangeNotifier {
8585
8686 /// Listens to [textEditingController] and is called whenever it changes.
8787 void _onTextControllerChange () {
88+ if (currentlySelectedAction? .actionType == CommandPaletteActionType .input) {
89+ return ;
90+ }
91+
8892 if (_enteredQuery != textEditingController.text) {
8993 _enteredQuery = textEditingController.text;
9094 _actionsNeedRefiltered = true ;
@@ -96,7 +100,8 @@ class CommandPaletteController extends ChangeNotifier {
96100 CommandPaletteAction ? get currentlySelectedAction => _currentlySelectedAction;
97101 set currentlySelectedAction (CommandPaletteAction ? newAction) {
98102 assert (newAction == null ||
99- newAction.actionType == CommandPaletteActionType .nested);
103+ newAction.actionType == CommandPaletteActionType .nested ||
104+ newAction.actionType == CommandPaletteActionType .input);
100105 _currentlySelectedAction = newAction;
101106 _actionsNeedRefiltered = true ;
102107 textEditingController.clear ();
@@ -118,6 +123,9 @@ class CommandPaletteController extends ChangeNotifier {
118123 if (currentlySelectedAction? .actionType ==
119124 CommandPaletteActionType .nested) {
120125 filteredActions = currentlySelectedAction! .childrenActions! ;
126+ } else if (currentlySelectedAction? .actionType ==
127+ CommandPaletteActionType .input) {
128+ filteredActions = [];
121129 } else {
122130 filteredActions = actions;
123131 }
@@ -193,14 +201,26 @@ class CommandPaletteController extends ChangeNotifier {
193201
194202 // nested items we set this item as the selected which in turn
195203 // will display its children.
196- else if (action.actionType == CommandPaletteActionType .nested) {
204+ else {
197205 currentlySelectedAction = action;
198206 }
199207 }
200208
209+ void handleActionInput (BuildContext context) {
210+ _currentlySelectedAction? .onConfirmInput !(textEditingController.text);
211+ if (Navigator .of (context).canPop ()) {
212+ Navigator .of (context).pop ();
213+ }
214+ }
215+
201216 /// performs the action which is currently selected by [highlightedAction]
202217 void performHighlightedAction (BuildContext context) {
203- handleAction (context, action: _filteredActionsCache[highlightedAction]);
218+ if (_currentlySelectedAction? .actionType ==
219+ CommandPaletteActionType .input) {
220+ handleActionInput (context);
221+ } else {
222+ handleAction (context, action: _filteredActionsCache[highlightedAction]);
223+ }
204224 }
205225}
206226
0 commit comments