mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
This commit is contained in:
parent
d7da6190ff
commit
36daea2d54
@ -3,4 +3,4 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
/// The pinned version of flutter gallery, used for devicelab tests.
|
/// The pinned version of flutter gallery, used for devicelab tests.
|
||||||
const String galleryVersion = 'bc7b2bba0bbcb54f30ffc0042120253c261aadeb';
|
const String galleryVersion = '4655d32d9d4724809ff2825d5469ff6f311c2cae';
|
||||||
|
@ -55,8 +55,7 @@ enum KeyEventResult {
|
|||||||
///
|
///
|
||||||
/// Returns a [KeyEventResult] that describes how, and whether, the key event
|
/// Returns a [KeyEventResult] that describes how, and whether, the key event
|
||||||
/// was handled.
|
/// was handled.
|
||||||
// TODO(gspencergoog): Convert this from dynamic to KeyEventResult once migration is complete.
|
typedef FocusOnKeyCallback = KeyEventResult Function(FocusNode node, RawKeyEvent event);
|
||||||
typedef FocusOnKeyCallback = dynamic Function(FocusNode node, RawKeyEvent event);
|
|
||||||
|
|
||||||
/// An attachment point for a [FocusNode].
|
/// An attachment point for a [FocusNode].
|
||||||
///
|
///
|
||||||
@ -1674,33 +1673,18 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
|
|||||||
bool handled = false;
|
bool handled = false;
|
||||||
for (final FocusNode node in <FocusNode>[_primaryFocus!, ..._primaryFocus!.ancestors]) {
|
for (final FocusNode node in <FocusNode>[_primaryFocus!, ..._primaryFocus!.ancestors]) {
|
||||||
if (node.onKey != null) {
|
if (node.onKey != null) {
|
||||||
// TODO(gspencergoog): Convert this from dynamic to KeyEventResult once migration is complete.
|
final KeyEventResult result = node.onKey!(node, event);
|
||||||
final dynamic result = node.onKey!(node, event);
|
switch (result) {
|
||||||
assert(
|
case KeyEventResult.handled:
|
||||||
result is bool || result is KeyEventResult,
|
|
||||||
'Value returned from onKey handler must be a non-null bool or KeyEventResult, not ${result.runtimeType}',
|
|
||||||
);
|
|
||||||
if (result is KeyEventResult) {
|
|
||||||
switch (result) {
|
|
||||||
case KeyEventResult.handled:
|
|
||||||
assert(_focusDebug('Node $node handled key event $event.'));
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
case KeyEventResult.skipRemainingHandlers:
|
|
||||||
assert(_focusDebug('Node $node stopped key event propagation: $event.'));
|
|
||||||
handled = false;
|
|
||||||
break;
|
|
||||||
case KeyEventResult.ignored:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if (result is bool){
|
|
||||||
if (result) {
|
|
||||||
assert(_focusDebug('Node $node handled key event $event.'));
|
assert(_focusDebug('Node $node handled key event $event.'));
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
} else {
|
case KeyEventResult.skipRemainingHandlers:
|
||||||
|
assert(_focusDebug('Node $node stopped key event propagation: $event.'));
|
||||||
|
handled = false;
|
||||||
|
break;
|
||||||
|
case KeyEventResult.ignored:
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1596,7 +1596,7 @@ void main() {
|
|||||||
bool? keyEventHandled;
|
bool? keyEventHandled;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Focus(
|
Focus(
|
||||||
onKey: (_, __) => true, // This one does nothing.
|
onKey: (_, __) => KeyEventResult.ignored, // This one does nothing.
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
child: Container(key: key1),
|
child: Container(key: key1),
|
||||||
),
|
),
|
||||||
@ -1611,7 +1611,7 @@ void main() {
|
|||||||
Focus(
|
Focus(
|
||||||
onKey: (FocusNode node, RawKeyEvent event) { // The updated handler handles the key.
|
onKey: (FocusNode node, RawKeyEvent event) { // The updated handler handles the key.
|
||||||
keyEventHandled = true;
|
keyEventHandled = true;
|
||||||
return true;
|
return KeyEventResult.handled;
|
||||||
},
|
},
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
child: Container(key: key1),
|
child: Container(key: key1),
|
||||||
|
Loading…
Reference in New Issue
Block a user