Repository navigation
Add PrioritizedIntents to support multiple shortcut configurations - #72560
Conversation
|
@gspencergoog perhaps for discussing after the holidays, this is what I had in mind for the multi-Intent we mentioned earlier this week. :) |
|
@Piinks This is super cool! I say write the test and ship it! |
|
@Piinks Is there any way to disable this functionality through an option e.g. prevent spacebar from scrolling with a boolean? |
Hey @devanflores you can provide your own shortcuts to |
|
@devanflores you can override any shortcut binding by placing a "Shortcuts" widget above the widgets you would like to override it for (or at the top of your app, as a child of the MaterialApp/CupertinoApp widget), defining a different shortcut binding for the same keys. You can also disable it entirely by binding it to a So, like this: |

Description
This adds a new Intent -
PrioritizedIntentsThis will allow for multiple Intents to be associated with a single
LogicalKeySet, so multiple Shortcuts can be evaluated.For example - the web platform expects that, in the right context, the spacebar will scroll a scroll view. This has not been possible because the spacebar also serves as a shortcut to activate switches and buttons.
In a
PrioritizedAction, the listedIntentswill be evaluated such that the rightActionwill be invoked. In our web case, theActivateIntentwill be evaluated first, followed by theScrollIntent. So if there were aCheckboxinside of aScrollView, the space bar shortcut could scroll the view or activate the checkbox, depending on the location of theprimaryFocus. The test case here shows this example.Related Issues
Fixes #43694
Tests
Shortcuts support multiple intents
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.