Skip to content

Commit

Permalink
RestorationManager should dispatch creation in constructor. (#133911)
Browse files Browse the repository at this point in the history
  • Loading branch information
polina-c authored Sep 8, 2023
1 parent 621ad98 commit 834f5dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/flutter/lib/src/services/restoration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ class RestorationManager extends ChangeNotifier {
/// Construct the restoration manager and set up the communications channels
/// with the engine to get restoration messages (by calling [initChannels]).
RestorationManager() {
if (kFlutterMemoryAllocationsEnabled) {
maybeDispatchObjectCreation();
}
initChannels();
}

Expand Down
5 changes: 5 additions & 0 deletions packages/flutter/test/services/restoration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

import 'restoration.dart';

void main() {
testWidgetsWithLeakTracking('$RestorationManager dispatches memory events', (WidgetTester tester) async {
expect(() => RestorationManager().dispose(), dispatchesMemoryEvents(RestorationManager));
});

group('RestorationManager', () {
testWidgets('root bucket retrieval', (WidgetTester tester) async {
final List<MethodCall> callsToEngine = <MethodCall>[];
Expand Down

0 comments on commit 834f5dc

Please sign in to comment.