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
ae64abc6
Unverified
Commit
ae64abc6
authored
Aug 29, 2023
by
Polina Cherkasova
Committed by
GitHub
Aug 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ShortcutManager should dispatch creation in constructor. (#133487)
parent
d8d7e019
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
9 deletions
+22
-9
shortcuts.dart
packages/flutter/lib/src/widgets/shortcuts.dart
+6
-1
text_selection_theme_test.dart
...ages/flutter/test/material/text_selection_theme_test.dart
+0
-2
shortcuts_test.dart
packages/flutter/test/widgets/shortcuts_test.dart
+16
-6
No files found.
packages/flutter/lib/src/widgets/shortcuts.dart
View file @
ae64abc6
...
@@ -747,7 +747,11 @@ class ShortcutManager with Diagnosticable, ChangeNotifier {
...
@@ -747,7 +747,11 @@ class ShortcutManager with Diagnosticable, ChangeNotifier {
ShortcutManager
({
ShortcutManager
({
Map
<
ShortcutActivator
,
Intent
>
shortcuts
=
const
<
ShortcutActivator
,
Intent
>{},
Map
<
ShortcutActivator
,
Intent
>
shortcuts
=
const
<
ShortcutActivator
,
Intent
>{},
this
.
modal
=
false
,
this
.
modal
=
false
,
})
:
_shortcuts
=
shortcuts
;
})
:
_shortcuts
=
shortcuts
{
if
(
kFlutterMemoryAllocationsEnabled
)
{
maybeDispatchObjectCreation
();
}
}
/// True if the [ShortcutManager] should not pass on keys that it doesn't
/// True if the [ShortcutManager] should not pass on keys that it doesn't
/// handle to any key-handling widgets that are ancestors to this one.
/// handle to any key-handling widgets that are ancestors to this one.
...
@@ -1440,6 +1444,7 @@ class _ShortcutRegistrarState extends State<ShortcutRegistrar> {
...
@@ -1440,6 +1444,7 @@ class _ShortcutRegistrarState extends State<ShortcutRegistrar> {
void
dispose
()
{
void
dispose
()
{
registry
.
removeListener
(
_shortcutsChanged
);
registry
.
removeListener
(
_shortcutsChanged
);
registry
.
dispose
();
registry
.
dispose
();
manager
.
dispose
();
super
.
dispose
();
super
.
dispose
();
}
}
...
...
packages/flutter/test/material/text_selection_theme_test.dart
View file @
ae64abc6
...
@@ -177,8 +177,6 @@ void main() {
...
@@ -177,8 +177,6 @@ void main() {
'ValueNotifier<bool>'
:
2
,
'ValueNotifier<bool>'
:
2
,
'_InputBorderGap'
:
1
,
'_InputBorderGap'
:
1
,
},
},
// TODO(polina-c): investigate notGCed, if it does not disappear after fixing notDisposed.
allowAllNotGCed:
true
,
),
),
);
);
...
...
packages/flutter/test/widgets/shortcuts_test.dart
View file @
ae64abc6
...
@@ -666,6 +666,19 @@ void main() {
...
@@ -666,6 +666,19 @@ void main() {
expect
(
pressedKeys
,
isEmpty
);
expect
(
pressedKeys
,
isEmpty
);
});
});
test
(
'
$ShortcutManager
dispatches object creation in constructor'
,
()
{
int
eventCount
=
0
;
void
listener
(
ObjectEvent
event
)
=>
eventCount
++;
MemoryAllocations
.
instance
.
addListener
(
listener
);
final
ShortcutManager
registry
=
ShortcutManager
();
expect
(
eventCount
,
1
);
registry
.
dispose
();
MemoryAllocations
.
instance
.
removeListener
(
listener
);
});
testWidgets
(
"Shortcuts passes to the next Shortcuts widget if it doesn't map the key"
,
(
WidgetTester
tester
)
async
{
testWidgets
(
"Shortcuts passes to the next Shortcuts widget if it doesn't map the key"
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
containerKey
=
GlobalKey
();
final
GlobalKey
containerKey
=
GlobalKey
();
final
List
<
LogicalKeyboardKey
>
pressedKeys
=
<
LogicalKeyboardKey
>[];
final
List
<
LogicalKeyboardKey
>
pressedKeys
=
<
LogicalKeyboardKey
>[];
...
@@ -1853,20 +1866,17 @@ void main() {
...
@@ -1853,20 +1866,17 @@ void main() {
token
.
dispose
();
token
.
dispose
();
});
});
testWidgets
(
'dispatches object creation in constructor'
,
(
WidgetTester
tester
)
async
{
test
(
'dispatches object creation in constructor'
,
()
{
final
MemoryAllocations
ma
=
MemoryAllocations
.
instance
;
assert
(!
ma
.
hasListeners
);
int
eventCount
=
0
;
int
eventCount
=
0
;
void
listener
(
ObjectEvent
event
)
=>
eventCount
++;
void
listener
(
ObjectEvent
event
)
=>
eventCount
++;
ma
.
addListener
(
listener
);
MemoryAllocations
.
instance
.
addListener
(
listener
);
final
ShortcutRegistry
registry
=
ShortcutRegistry
();
final
ShortcutRegistry
registry
=
ShortcutRegistry
();
expect
(
eventCount
,
1
);
expect
(
eventCount
,
1
);
registry
.
dispose
();
registry
.
dispose
();
ma
.
removeListener
(
listener
);
MemoryAllocations
.
instance
.
removeListener
(
listener
);
assert
(!
ma
.
hasListeners
);
});
});
});
});
}
}
...
...
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