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
0fdc4e88
Unverified
Commit
0fdc4e88
authored
Apr 13, 2021
by
Jenn Magder
Committed by
GitHub
Apr 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Remove a dynamic that is no longer necessary (and the TODO for it) (#80294)" (#80326)
This reverts commit
12ec7dc8
.
parent
fbf3c4e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
11 deletions
+27
-11
focus_manager.dart
packages/flutter/lib/src/widgets/focus_manager.dart
+25
-9
focus_scope_test.dart
packages/flutter/test/widgets/focus_scope_test.dart
+2
-2
No files found.
packages/flutter/lib/src/widgets/focus_manager.dart
View file @
0fdc4e88
...
...
@@ -55,7 +55,8 @@ enum KeyEventResult {
///
/// Returns a [KeyEventResult] that describes how, and whether, the key event
/// was handled.
typedef
FocusOnKeyCallback
=
KeyEventResult
Function
(
FocusNode
node
,
RawKeyEvent
event
);
// TODO(gspencergoog): Convert this from dynamic to KeyEventResult once migration is complete.
typedef
FocusOnKeyCallback
=
dynamic
Function
(
FocusNode
node
,
RawKeyEvent
event
);
/// An attachment point for a [FocusNode].
///
...
...
@@ -1673,18 +1674,33 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
bool
handled
=
false
;
for
(
final
FocusNode
node
in
<
FocusNode
>[
_primaryFocus
!,
...
_primaryFocus
!.
ancestors
])
{
if
(
node
.
onKey
!=
null
)
{
final
KeyEventResult
result
=
node
.
onKey
!(
node
,
event
);
switch
(
result
)
{
case
KeyEventResult
.
handled
:
// TODO(gspencergoog): Convert this from dynamic to KeyEventResult once migration is complete.
final
dynamic
result
=
node
.
onKey
!(
node
,
event
);
assert
(
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
.'
));
handled
=
true
;
break
;
case
KeyEventResult
.
skipRemainingHandlers
:
assert
(
_focusDebug
(
'Node
$node
stopped key event propagation:
$event
.'
));
handled
=
false
;
break
;
case
KeyEventResult
.
ignored
:
}
else
{
continue
;
}
}
break
;
}
...
...
packages/flutter/test/widgets/focus_scope_test.dart
View file @
0fdc4e88
...
...
@@ -1596,7 +1596,7 @@ void main() {
bool
?
keyEventHandled
;
await
tester
.
pumpWidget
(
Focus
(
onKey:
(
_
,
__
)
=>
KeyEventResult
.
ignored
,
// This one does nothing.
onKey:
(
_
,
__
)
=>
true
,
// This one does nothing.
focusNode:
focusNode
,
child:
Container
(
key:
key1
),
),
...
...
@@ -1611,7 +1611,7 @@ void main() {
Focus
(
onKey:
(
FocusNode
node
,
RawKeyEvent
event
)
{
// The updated handler handles the key.
keyEventHandled
=
true
;
return
KeyEventResult
.
handled
;
return
true
;
},
focusNode:
focusNode
,
child:
Container
(
key:
key1
),
...
...
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