Skip to content

Commit ec387a4

Browse files
authored
Revert "ShortcutManager should dispatch creation in constructor." (flutter#133472)
Reverts flutter#133356 Tree is failing on customer_testing on this PR. https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20customer_testing/14646/overview
1 parent 05259ca commit ec387a4

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

packages/flutter/lib/src/widgets/shortcuts.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,11 +747,7 @@ class ShortcutManager with Diagnosticable, ChangeNotifier {
747747
ShortcutManager({
748748
Map<ShortcutActivator, Intent> shortcuts = const <ShortcutActivator, Intent>{},
749749
this.modal = false,
750-
}) : _shortcuts = shortcuts {
751-
if (kFlutterMemoryAllocationsEnabled) {
752-
maybeDispatchObjectCreation();
753-
}
754-
}
750+
}) : _shortcuts = shortcuts;
755751

756752
/// True if the [ShortcutManager] should not pass on keys that it doesn't
757753
/// handle to any key-handling widgets that are ancestors to this one.
@@ -1444,7 +1440,6 @@ class _ShortcutRegistrarState extends State<ShortcutRegistrar> {
14441440
void dispose() {
14451441
registry.removeListener(_shortcutsChanged);
14461442
registry.dispose();
1447-
manager.dispose();
14481443
super.dispose();
14491444
}
14501445

packages/flutter/test/widgets/shortcuts_test.dart

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -666,19 +666,6 @@ void main() {
666666
expect(pressedKeys, isEmpty);
667667
});
668668

669-
test('$ShortcutManager dispatches object creation in constructor', () {
670-
int eventCount = 0;
671-
void listener(ObjectEvent event) => eventCount++;
672-
MemoryAllocations.instance.addListener(listener);
673-
674-
final ShortcutManager registry = ShortcutManager();
675-
676-
expect(eventCount, 1);
677-
678-
registry.dispose();
679-
MemoryAllocations.instance.removeListener(listener);
680-
});
681-
682669
testWidgets("Shortcuts passes to the next Shortcuts widget if it doesn't map the key", (WidgetTester tester) async {
683670
final GlobalKey containerKey = GlobalKey();
684671
final List<LogicalKeyboardKey> pressedKeys = <LogicalKeyboardKey>[];
@@ -1866,17 +1853,20 @@ void main() {
18661853
token.dispose();
18671854
});
18681855

1869-
test('dispatches object creation in constructor', () {
1856+
testWidgets('dispatches object creation in constructor', (WidgetTester tester) async {
1857+
final MemoryAllocations ma = MemoryAllocations.instance;
1858+
assert(!ma.hasListeners);
18701859
int eventCount = 0;
18711860
void listener(ObjectEvent event) => eventCount++;
1872-
MemoryAllocations.instance.addListener(listener);
1861+
ma.addListener(listener);
18731862

18741863
final ShortcutRegistry registry = ShortcutRegistry();
18751864

18761865
expect(eventCount, 1);
18771866

18781867
registry.dispose();
1879-
MemoryAllocations.instance.removeListener(listener);
1868+
ma.removeListener(listener);
1869+
assert(!ma.hasListeners);
18801870
});
18811871
});
18821872
}

0 commit comments

Comments
 (0)