Unverified Commit b8833afc authored by Tong Mu's avatar Tong Mu Committed by GitHub

Migrate LogicalKeySet to SingleActivator (#80756)

Applies #78522 to existing code, by replacing all occurrences of LogicalKeySet to SingleActivator or ShortcutActivator.
parent 635c997a
...@@ -406,9 +406,9 @@ class _FocusDemoState extends State<FocusDemo> { ...@@ -406,9 +406,9 @@ class _FocusDemoState extends State<FocusDemo> {
child: FocusTraversalGroup( child: FocusTraversalGroup(
policy: ReadingOrderTraversalPolicy(), policy: ReadingOrderTraversalPolicy(),
child: Shortcuts( child: Shortcuts(
shortcuts: <LogicalKeySet, Intent>{ shortcuts: <ShortcutActivator, Intent>{
LogicalKeySet(Platform.isMacOS ? LogicalKeyboardKey.meta : LogicalKeyboardKey.control, LogicalKeyboardKey.shift, LogicalKeyboardKey.keyZ): const RedoIntent(), SingleActivator(LogicalKeyboardKey.keyZ, meta: Platform.isMacOS, control: !Platform.isMacOS, shift: true): const RedoIntent(),
LogicalKeySet(Platform.isMacOS ? LogicalKeyboardKey.meta : LogicalKeyboardKey.control, LogicalKeyboardKey.keyZ): const UndoIntent(), SingleActivator(LogicalKeyboardKey.keyZ, meta: Platform.isMacOS, control: !Platform.isMacOS): const UndoIntent(),
}, },
child: FocusScope( child: FocusScope(
key: FocusDemo.appKey, key: FocusDemo.appKey,
......
...@@ -346,9 +346,9 @@ class CupertinoApp extends StatefulWidget { ...@@ -346,9 +346,9 @@ class CupertinoApp extends StatefulWidget {
/// ```dart /// ```dart
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return WidgetsApp( /// return WidgetsApp(
/// shortcuts: <LogicalKeySet, Intent>{ /// shortcuts: <ShortcutActivator, Intent>{
/// ... WidgetsApp.defaultShortcuts, /// ... WidgetsApp.defaultShortcuts,
/// LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(), /// const SingleActivator(LogicalKeyboardKey.select): const ActivateIntent(),
/// }, /// },
/// color: const Color(0xFFFF0000), /// color: const Color(0xFFFF0000),
/// builder: (BuildContext context, Widget? child) { /// builder: (BuildContext context, Widget? child) {
...@@ -359,7 +359,7 @@ class CupertinoApp extends StatefulWidget { ...@@ -359,7 +359,7 @@ class CupertinoApp extends StatefulWidget {
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
/// {@macro flutter.widgets.widgetsApp.shortcuts.seeAlso} /// {@macro flutter.widgets.widgetsApp.shortcuts.seeAlso}
final Map<LogicalKeySet, Intent>? shortcuts; final Map<ShortcutActivator, Intent>? shortcuts;
/// {@macro flutter.widgets.widgetsApp.actions} /// {@macro flutter.widgets.widgetsApp.actions}
/// {@tool snippet} /// {@tool snippet}
......
...@@ -584,9 +584,9 @@ class MaterialApp extends StatefulWidget { ...@@ -584,9 +584,9 @@ class MaterialApp extends StatefulWidget {
/// ```dart /// ```dart
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return WidgetsApp( /// return WidgetsApp(
/// shortcuts: <LogicalKeySet, Intent>{ /// shortcuts: <ShortcutActivator, Intent>{
/// ... WidgetsApp.defaultShortcuts, /// ... WidgetsApp.defaultShortcuts,
/// LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(), /// const SingleActivator(LogicalKeyboardKey.select): const ActivateIntent(),
/// }, /// },
/// color: const Color(0xFFFF0000), /// color: const Color(0xFFFF0000),
/// builder: (BuildContext context, Widget? child) { /// builder: (BuildContext context, Widget? child) {
...@@ -597,7 +597,7 @@ class MaterialApp extends StatefulWidget { ...@@ -597,7 +597,7 @@ class MaterialApp extends StatefulWidget {
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
/// {@macro flutter.widgets.widgetsApp.shortcuts.seeAlso} /// {@macro flutter.widgets.widgetsApp.shortcuts.seeAlso}
final Map<LogicalKeySet, Intent>? shortcuts; final Map<ShortcutActivator, Intent>? shortcuts;
/// {@macro flutter.widgets.widgetsApp.actions} /// {@macro flutter.widgets.widgetsApp.actions}
/// {@tool snippet} /// {@tool snippet}
......
...@@ -495,7 +495,7 @@ class _MonthPickerState extends State<_MonthPicker> { ...@@ -495,7 +495,7 @@ class _MonthPickerState extends State<_MonthPicker> {
late PageController _pageController; late PageController _pageController;
late MaterialLocalizations _localizations; late MaterialLocalizations _localizations;
late TextDirection _textDirection; late TextDirection _textDirection;
Map<LogicalKeySet, Intent>? _shortcutMap; Map<ShortcutActivator, Intent>? _shortcutMap;
Map<Type, Action<Intent>>? _actionMap; Map<Type, Action<Intent>>? _actionMap;
late FocusNode _dayGridFocus; late FocusNode _dayGridFocus;
DateTime? _focusedDay; DateTime? _focusedDay;
...@@ -507,11 +507,11 @@ class _MonthPickerState extends State<_MonthPicker> { ...@@ -507,11 +507,11 @@ class _MonthPickerState extends State<_MonthPicker> {
_previousMonthDate = DateUtils.addMonthsToMonthDate(_currentMonth, -1); _previousMonthDate = DateUtils.addMonthsToMonthDate(_currentMonth, -1);
_nextMonthDate = DateUtils.addMonthsToMonthDate(_currentMonth, 1); _nextMonthDate = DateUtils.addMonthsToMonthDate(_currentMonth, 1);
_pageController = PageController(initialPage: DateUtils.monthDelta(widget.firstDate, _currentMonth)); _pageController = PageController(initialPage: DateUtils.monthDelta(widget.firstDate, _currentMonth));
_shortcutMap = <LogicalKeySet, Intent>{ _shortcutMap = const <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.arrowLeft): const DirectionalFocusIntent(TraversalDirection.left), SingleActivator(LogicalKeyboardKey.arrowLeft): DirectionalFocusIntent(TraversalDirection.left),
LogicalKeySet(LogicalKeyboardKey.arrowRight): const DirectionalFocusIntent(TraversalDirection.right), SingleActivator(LogicalKeyboardKey.arrowRight): DirectionalFocusIntent(TraversalDirection.right),
LogicalKeySet(LogicalKeyboardKey.arrowDown): const DirectionalFocusIntent(TraversalDirection.down), SingleActivator(LogicalKeyboardKey.arrowDown): DirectionalFocusIntent(TraversalDirection.down),
LogicalKeySet(LogicalKeyboardKey.arrowUp): const DirectionalFocusIntent(TraversalDirection.up), SingleActivator(LogicalKeyboardKey.arrowUp): DirectionalFocusIntent(TraversalDirection.up),
}; };
_actionMap = <Type, Action<Intent>>{ _actionMap = <Type, Action<Intent>>{
NextFocusIntent: CallbackAction<NextFocusIntent>(onInvoke: _handleGridNextFocus), NextFocusIntent: CallbackAction<NextFocusIntent>(onInvoke: _handleGridNextFocus),
......
...@@ -496,9 +496,9 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix ...@@ -496,9 +496,9 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
} }
} }
static final Map<LogicalKeySet, Intent> _formShortcutMap = <LogicalKeySet, Intent>{ static const Map<ShortcutActivator, Intent> _formShortcutMap = <ShortcutActivator, Intent>{
// Pressing enter on the field will move focus to the next field or control. // Pressing enter on the field will move focus to the next field or control.
LogicalKeySet(LogicalKeyboardKey.enter): const NextFocusIntent(), SingleActivator(LogicalKeyboardKey.enter): NextFocusIntent(),
}; };
@override @override
...@@ -1902,7 +1902,12 @@ class _CalendarKeyboardNavigator extends StatefulWidget { ...@@ -1902,7 +1902,12 @@ class _CalendarKeyboardNavigator extends StatefulWidget {
class _CalendarKeyboardNavigatorState extends State<_CalendarKeyboardNavigator> { class _CalendarKeyboardNavigatorState extends State<_CalendarKeyboardNavigator> {
late Map<LogicalKeySet, Intent> _shortcutMap; final Map<ShortcutActivator, Intent> _shortcutMap = const <ShortcutActivator, Intent>{
SingleActivator(LogicalKeyboardKey.arrowLeft): DirectionalFocusIntent(TraversalDirection.left),
SingleActivator(LogicalKeyboardKey.arrowRight): DirectionalFocusIntent(TraversalDirection.right),
SingleActivator(LogicalKeyboardKey.arrowDown): DirectionalFocusIntent(TraversalDirection.down),
SingleActivator(LogicalKeyboardKey.arrowUp): DirectionalFocusIntent(TraversalDirection.up),
};
late Map<Type, Action<Intent>> _actionMap; late Map<Type, Action<Intent>> _actionMap;
late FocusNode _dayGridFocus; late FocusNode _dayGridFocus;
TraversalDirection? _dayTraversalDirection; TraversalDirection? _dayTraversalDirection;
...@@ -1912,12 +1917,6 @@ class _CalendarKeyboardNavigatorState extends State<_CalendarKeyboardNavigator> ...@@ -1912,12 +1917,6 @@ class _CalendarKeyboardNavigatorState extends State<_CalendarKeyboardNavigator>
void initState() { void initState() {
super.initState(); super.initState();
_shortcutMap = <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.arrowLeft): const DirectionalFocusIntent(TraversalDirection.left),
LogicalKeySet(LogicalKeyboardKey.arrowRight): const DirectionalFocusIntent(TraversalDirection.right),
LogicalKeySet(LogicalKeyboardKey.arrowDown): const DirectionalFocusIntent(TraversalDirection.down),
LogicalKeySet(LogicalKeyboardKey.arrowUp): const DirectionalFocusIntent(TraversalDirection.up),
};
_actionMap = <Type, Action<Intent>>{ _actionMap = <Type, Action<Intent>>{
NextFocusIntent: CallbackAction<NextFocusIntent>(onInvoke: _handleGridNextFocus), NextFocusIntent: CallbackAction<NextFocusIntent>(onInvoke: _handleGridNextFocus),
PreviousFocusIntent: CallbackAction<PreviousFocusIntent>(onInvoke: _handleGridPreviousFocus), PreviousFocusIntent: CallbackAction<PreviousFocusIntent>(onInvoke: _handleGridPreviousFocus),
......
...@@ -148,11 +148,11 @@ class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>> ...@@ -148,11 +148,11 @@ class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>>
); );
} }
static final Map<LogicalKeySet, Intent> _webShortcuts =<LogicalKeySet, Intent>{ static const Map<ShortcutActivator, Intent> _webShortcuts = <ShortcutActivator, Intent>{
// On the web, up/down don't change focus, *except* in a <select> // On the web, up/down don't change focus, *except* in a <select>
// element, which is what a dropdown emulates. // element, which is what a dropdown emulates.
LogicalKeySet(LogicalKeyboardKey.arrowDown): const DirectionalFocusIntent(TraversalDirection.down), SingleActivator(LogicalKeyboardKey.arrowDown): DirectionalFocusIntent(TraversalDirection.down),
LogicalKeySet(LogicalKeyboardKey.arrowUp): const DirectionalFocusIntent(TraversalDirection.up), SingleActivator(LogicalKeyboardKey.arrowUp): DirectionalFocusIntent(TraversalDirection.up),
}; };
@override @override
......
...@@ -477,7 +477,12 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin { ...@@ -477,7 +477,12 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
final GlobalKey _renderObjectKey = GlobalKey(); final GlobalKey _renderObjectKey = GlobalKey();
// Keyboard mapping for a focused slider. // Keyboard mapping for a focused slider.
late Map<LogicalKeySet, Intent> _shortcutMap; final Map<ShortcutActivator, Intent> _shortcutMap = const <ShortcutActivator, Intent>{
SingleActivator(LogicalKeyboardKey.arrowUp): _AdjustSliderIntent.up(),
SingleActivator(LogicalKeyboardKey.arrowDown): _AdjustSliderIntent.down(),
SingleActivator(LogicalKeyboardKey.arrowLeft): _AdjustSliderIntent.left(),
SingleActivator(LogicalKeyboardKey.arrowRight): _AdjustSliderIntent.right(),
};
// Action mapping for a focused slider. // Action mapping for a focused slider.
late Map<Type, Action<Intent>> _actionMap; late Map<Type, Action<Intent>> _actionMap;
...@@ -506,12 +511,6 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin { ...@@ -506,12 +511,6 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
); );
enableController.value = widget.onChanged != null ? 1.0 : 0.0; enableController.value = widget.onChanged != null ? 1.0 : 0.0;
positionController.value = _unlerp(widget.value); positionController.value = _unlerp(widget.value);
_shortcutMap = <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.arrowUp): const _AdjustSliderIntent.up(),
LogicalKeySet(LogicalKeyboardKey.arrowDown): const _AdjustSliderIntent.down(),
LogicalKeySet(LogicalKeyboardKey.arrowLeft): const _AdjustSliderIntent.left(),
LogicalKeySet(LogicalKeyboardKey.arrowRight): const _AdjustSliderIntent.right(),
};
_actionMap = <Type, Action<Intent>>{ _actionMap = <Type, Action<Intent>>{
_AdjustSliderIntent: CallbackAction<_AdjustSliderIntent>( _AdjustSliderIntent: CallbackAction<_AdjustSliderIntent>(
onInvoke: _actionHandler, onInvoke: _actionHandler,
......
...@@ -81,9 +81,9 @@ export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType; ...@@ -81,9 +81,9 @@ export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType;
/// return Material( /// return Material(
/// child: Center( /// child: Center(
/// child: Shortcuts( /// child: Shortcuts(
/// shortcuts: <LogicalKeySet, Intent>{ /// shortcuts: const <ShortcutActivator, Intent>{
/// // Pressing space in the field will now move to the next field. /// // Pressing space in the field will now move to the next field.
/// LogicalKeySet(LogicalKeyboardKey.space): const NextFocusIntent(), /// SingleActivator(LogicalKeyboardKey.space): NextFocusIntent(),
/// }, /// },
/// child: FocusTraversalGroup( /// child: FocusTraversalGroup(
/// child: Form( /// child: Form(
......
...@@ -1136,8 +1136,10 @@ class _ActionsMarker extends InheritedWidget { ...@@ -1136,8 +1136,10 @@ class _ActionsMarker extends InheritedWidget {
/// bool _focused = false; /// bool _focused = false;
/// bool _hovering = false; /// bool _hovering = false;
/// bool _on = false; /// bool _on = false;
/// late Map<Type, Action<Intent>> _actionMap; /// late final Map<Type, Action<Intent>> _actionMap;
/// late Map<LogicalKeySet, Intent> _shortcutMap; /// final Map<ShortcutActivator, Intent> _shortcutMap = const <ShortcutActivator, Intent>{
/// SingleActivator(LogicalKeyboardKey.keyX): ActivateIntent(),
/// };
/// ///
/// @override /// @override
/// void initState() { /// void initState() {
...@@ -1147,9 +1149,6 @@ class _ActionsMarker extends InheritedWidget { ...@@ -1147,9 +1149,6 @@ class _ActionsMarker extends InheritedWidget {
/// onInvoke: (Intent intent) => _toggleState(), /// onInvoke: (Intent intent) => _toggleState(),
/// ), /// ),
/// }; /// };
/// _shortcutMap = <LogicalKeySet, Intent>{
/// LogicalKeySet(LogicalKeyboardKey.keyX): const ActivateIntent(),
/// };
/// } /// }
/// ///
/// Color get color { /// Color get color {
...@@ -1287,7 +1286,7 @@ class FocusableActionDetector extends StatefulWidget { ...@@ -1287,7 +1286,7 @@ class FocusableActionDetector extends StatefulWidget {
final Map<Type, Action<Intent>>? actions; final Map<Type, Action<Intent>>? actions;
/// {@macro flutter.widgets.shortcuts.shortcuts} /// {@macro flutter.widgets.shortcuts.shortcuts}
final Map<LogicalKeySet, Intent>? shortcuts; final Map<ShortcutActivator, Intent>? shortcuts;
/// A function that will be called when the focus highlight should be shown or /// A function that will be called when the focus highlight should be shown or
/// hidden. /// hidden.
......
This diff is collapsed.
...@@ -355,7 +355,7 @@ class LogicalKeySet extends KeySet<LogicalKeyboardKey> with Diagnosticable ...@@ -355,7 +355,7 @@ class LogicalKeySet extends KeySet<LogicalKeyboardKey> with Diagnosticable
/// Intent>` (the same type as the [Shortcuts.shortcuts] property) so that its /// Intent>` (the same type as the [Shortcuts.shortcuts] property) so that its
/// diagnostic output is human-readable. /// diagnostic output is human-readable.
class ShortcutMapProperty extends DiagnosticsProperty<Map<ShortcutActivator, Intent>> { class ShortcutMapProperty extends DiagnosticsProperty<Map<ShortcutActivator, Intent>> {
/// Create a diagnostics property for `Map<LogicalKeySet, Intent>` objects, /// Create a diagnostics property for `Map<ShortcutActivator, Intent>` objects,
/// which are the same type as the [Shortcuts.shortcuts] property. /// which are the same type as the [Shortcuts.shortcuts] property.
ShortcutMapProperty( ShortcutMapProperty(
String name, String name,
......
...@@ -260,8 +260,8 @@ void main() { ...@@ -260,8 +260,8 @@ void main() {
Future<void> buildTest(Intent intent) async { Future<void> buildTest(Intent intent) async {
return tester.pumpWidget( return tester.pumpWidget(
Shortcuts( Shortcuts(
shortcuts: <LogicalKeySet, Intent>{ shortcuts: <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.space): intent, const SingleActivator(LogicalKeyboardKey.space): intent,
}, },
child: Directionality( child: Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -82,9 +82,9 @@ void main() { ...@@ -82,9 +82,9 @@ void main() {
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Shortcuts( child: Shortcuts(
shortcuts: <LogicalKeySet, Intent>{ shortcuts: const <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.space): const ActivateIntent(), SingleActivator(LogicalKeyboardKey.space): ActivateIntent(),
LogicalKeySet(LogicalKeyboardKey.enter): const ButtonActivateIntent(), SingleActivator(LogicalKeyboardKey.enter): ButtonActivateIntent(),
}, },
child: Material( child: Material(
child: Center( child: Center(
......
...@@ -46,9 +46,9 @@ void main() { ...@@ -46,9 +46,9 @@ void main() {
const Color splashColor = Color(0xff00ff00); const Color splashColor = Color(0xff00ff00);
await tester.pumpWidget( await tester.pumpWidget(
Shortcuts( Shortcuts(
shortcuts: <LogicalKeySet, Intent>{ shortcuts: const <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.enter): const ActivateIntent(), SingleActivator(LogicalKeyboardKey.enter): ActivateIntent(),
LogicalKeySet(LogicalKeyboardKey.space): const ActivateIntent(), SingleActivator(LogicalKeyboardKey.space): ActivateIntent(),
}, },
child: Directionality( child: Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -414,8 +414,8 @@ void main() { ...@@ -414,8 +414,8 @@ void main() {
child: FocusableActionDetector( child: FocusableActionDetector(
enabled: enabled, enabled: enabled,
focusNode: focusNode, focusNode: focusNode,
shortcuts: <LogicalKeySet, Intent>{ shortcuts: const <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.enter): intent, SingleActivator(LogicalKeyboardKey.enter): intent,
}, },
actions: <Type, Action<Intent>>{ actions: <Type, Action<Intent>>{
TestIntent: testAction, TestIntent: testAction,
...@@ -789,8 +789,8 @@ void main() { ...@@ -789,8 +789,8 @@ void main() {
child: FocusableActionDetector( child: FocusableActionDetector(
enabled: enabled, enabled: enabled,
focusNode: focusNode, focusNode: focusNode,
shortcuts: <LogicalKeySet, Intent>{ shortcuts: const <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.enter): intent, SingleActivator(LogicalKeyboardKey.enter): intent,
}, },
actions: <Type, Action<Intent>>{ actions: <Type, Action<Intent>>{
TestIntent: testAction, TestIntent: testAction,
......
...@@ -76,8 +76,8 @@ void main() { ...@@ -76,8 +76,8 @@ void main() {
actions: <Type, Action<Intent>>{ actions: <Type, Action<Intent>>{
TestIntent: action, TestIntent: action,
}, },
shortcuts: <LogicalKeySet, Intent> { shortcuts: const <ShortcutActivator, Intent> {
LogicalKeySet(LogicalKeyboardKey.space): const TestIntent(), SingleActivator(LogicalKeyboardKey.space): TestIntent(),
}, },
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return Material( return Material(
......
...@@ -6,8 +6,12 @@ import 'package:flutter/material.dart'; ...@@ -6,8 +6,12 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
class TestLeftIntent extends Intent {} class TestLeftIntent extends Intent {
class TestRightIntent extends Intent {} const TestLeftIntent();
}
class TestRightIntent extends Intent {
const TestRightIntent();
}
void main() { void main() {
testWidgets('DoNothingAndStopPropagationTextIntent', (WidgetTester tester) async { testWidgets('DoNothingAndStopPropagationTextIntent', (WidgetTester tester) async {
...@@ -25,13 +29,13 @@ void main() { ...@@ -25,13 +29,13 @@ void main() {
body: Builder( body: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return Shortcuts( return Shortcuts(
shortcuts: <LogicalKeySet, Intent>{ shortcuts: const <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.arrowLeft): TestLeftIntent(), SingleActivator(LogicalKeyboardKey.arrowLeft): TestLeftIntent(),
LogicalKeySet(LogicalKeyboardKey.arrowRight): TestRightIntent(), SingleActivator(LogicalKeyboardKey.arrowRight): TestRightIntent(),
}, },
child: Shortcuts( child: Shortcuts(
shortcuts: <LogicalKeySet, Intent>{ shortcuts: const <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.arrowRight): const DoNothingAndStopPropagationTextIntent(), SingleActivator(LogicalKeyboardKey.arrowRight): DoNothingAndStopPropagationTextIntent(),
}, },
child: Actions( child: Actions(
// These Actions intercept default Intents, set a flag that they // These Actions intercept default Intents, set a flag that they
......
...@@ -7074,8 +7074,8 @@ void main() { ...@@ -7074,8 +7074,8 @@ void main() {
child: SizedBox( child: SizedBox(
width: 400, width: 400,
child: Shortcuts( child: Shortcuts(
shortcuts: <LogicalKeySet, Intent>{ shortcuts: const <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.arrowLeft): const MoveSelectionRightTextIntent(), SingleActivator(LogicalKeyboardKey.arrowLeft): MoveSelectionRightTextIntent(),
}, },
child: EditableText( child: EditableText(
maxLines: 10, maxLines: 10,
......
...@@ -1893,11 +1893,11 @@ void main() { ...@@ -1893,11 +1893,11 @@ void main() {
final FocusNode focusNodeLowerRight = FocusNode(debugLabel: 'lowerRight'); final FocusNode focusNodeLowerRight = FocusNode(debugLabel: 'lowerRight');
Widget generateTestWidgets(bool ignoreTextFields) { Widget generateTestWidgets(bool ignoreTextFields) {
final Map<LogicalKeySet, Intent> shortcuts = <LogicalKeySet, Intent>{ final Map<ShortcutActivator, Intent> shortcuts = <ShortcutActivator, Intent>{
LogicalKeySet(LogicalKeyboardKey.arrowLeft): DirectionalFocusIntent(TraversalDirection.left, ignoreTextFields: ignoreTextFields), const SingleActivator(LogicalKeyboardKey.arrowLeft): DirectionalFocusIntent(TraversalDirection.left, ignoreTextFields: ignoreTextFields),
LogicalKeySet(LogicalKeyboardKey.arrowRight): DirectionalFocusIntent(TraversalDirection.right, ignoreTextFields: ignoreTextFields), const SingleActivator(LogicalKeyboardKey.arrowRight): DirectionalFocusIntent(TraversalDirection.right, ignoreTextFields: ignoreTextFields),
LogicalKeySet(LogicalKeyboardKey.arrowDown): DirectionalFocusIntent(TraversalDirection.down, ignoreTextFields: ignoreTextFields), const SingleActivator(LogicalKeyboardKey.arrowDown): DirectionalFocusIntent(TraversalDirection.down, ignoreTextFields: ignoreTextFields),
LogicalKeySet(LogicalKeyboardKey.arrowUp): DirectionalFocusIntent(TraversalDirection.up, ignoreTextFields: ignoreTextFields), const SingleActivator(LogicalKeyboardKey.arrowUp): DirectionalFocusIntent(TraversalDirection.up, ignoreTextFields: ignoreTextFields),
}; };
return MaterialApp( return MaterialApp(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment