Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
52b4f725
Unverified
Commit
52b4f725
authored
Nov 05, 2020
by
Arpan Patel
Committed by
GitHub
Nov 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AdoptAWidget: Shortcut (#69568)
* Added Interactive Sample
parent
31972299
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
shortcuts.dart
packages/flutter/lib/src/widgets/shortcuts.dart
+51
-0
No files found.
packages/flutter/lib/src/widgets/shortcuts.dart
View file @
52b4f725
...
...
@@ -386,6 +386,57 @@ class ShortcutManager extends ChangeNotifier with Diagnosticable {
/// when invoking an [Action] via a keyboard key combination that maps to an
/// [Intent].
///
/// {@tool dartpad --template=stateful_widget_scaffold_center}
///
/// Here, we will use a [Shortcuts] and [Actions] widget to add and remove from a counter.
/// This can be done by creating a child widget that is focused and pressing the logical key
/// sets that have been defined in [Shortcuts] and defining the actions that each key set
/// performs.
///
/// ```dart imports
/// import 'package:flutter/services.dart';
/// ```
///
/// ```dart preamble
/// class Increment extends Intent {}
///
/// class Decrement extends Intent {}
/// ```
///
/// ```dart
/// int count = 0;
///
/// Widget build(BuildContext context) {
/// return Shortcuts(
/// shortcuts: <LogicalKeySet, Intent> {
/// LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.keyK): Increment(),
/// LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.keyL): Decrement(),
/// },
/// child: Actions(
/// actions: <Type, Action<Intent>> {
/// Increment: CallbackAction<Increment>(
/// onInvoke: (Increment intent) => setState(() { count = count + 1; }),
/// ),
/// Decrement: CallbackAction<Decrement>(
/// onInvoke: (Decrement intent) => setState(() { count = count - 1; }),
/// ),
/// },
/// child: Focus(
/// autofocus:true,
/// child: Column(
/// children: <Widget>[
/// Text('Add to the counter by pressing keyboard Shift and keyboard "K"'),
/// Text('Subtract from the counter by pressing keyboard Shift and keyboard "L"'),
/// Text('count: $count'),
/// ],
/// ),
/// ),
/// ),
/// );
/// }
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [Intent], a class for containing a description of a user action to be
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment