diff --git a/packages/go_router/pubspec.yaml b/packages/go_router/pubspec.yaml index ce916a07f3d9..7bfc3f9297f6 100644 --- a/packages/go_router/pubspec.yaml +++ b/packages/go_router/pubspec.yaml @@ -22,6 +22,7 @@ dev_dependencies: flutter_test: sdk: flutter io: ^1.0.4 + leak_tracker_flutter_testing: any path: ^1.8.2 topics: diff --git a/packages/go_router/test/extra_codec_test.dart b/packages/go_router/test/extra_codec_test.dart index 35291db978d8..0005d1d535ff 100644 --- a/packages/go_router/test/extra_codec_test.dart +++ b/packages/go_router/test/extra_codec_test.dart @@ -74,6 +74,7 @@ void main() { expect(find.text(initialString), findsOneWidget); await tester.restartAndRestore(); + addTearDown(tester.binding.restorationManager.dispose); await tester.pumpAndSettle(); expect(find.text(initialString), findsOneWidget); diff --git a/packages/go_router/test/flutter_test_config.dart b/packages/go_router/test/flutter_test_config.dart new file mode 100644 index 000000000000..9907e578b84b --- /dev/null +++ b/packages/go_router/test/flutter_test_config.dart @@ -0,0 +1,13 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; + +Future testExecutable(FutureOr Function() testMain) async { + LeakTesting.enable(); + LeakTracking.warnForUnsupportedPlatforms = false; + await testMain(); +} diff --git a/packages/go_router/test/go_router_test.dart b/packages/go_router/test/go_router_test.dart index a852805265c7..f2c0a69bd267 100644 --- a/packages/go_router/test/go_router_test.dart +++ b/packages/go_router/test/go_router_test.dart @@ -5458,6 +5458,7 @@ void main() { ), ], ); + addTearDown(router.dispose); await tester.pumpWidget( MaterialApp.router( key: UniqueKey(), diff --git a/packages/go_router/test/information_provider_test.dart b/packages/go_router/test/information_provider_test.dart index 591360366663..2bdb0e6178f9 100644 --- a/packages/go_router/test/information_provider_test.dart +++ b/packages/go_router/test/information_provider_test.dart @@ -17,6 +17,7 @@ void main() { late final GoRouteInformationProvider provider = GoRouteInformationProvider( initialLocation: initialRoute, initialExtra: null); + addTearDown(provider.dispose); provider.addListener(expectAsync0(() {})); provider.go(newRoute); }); @@ -26,6 +27,7 @@ void main() { late final GoRouteInformationProvider provider = GoRouteInformationProvider( initialLocation: initialRoute, initialExtra: null); + addTearDown(provider.dispose); provider.addListener(expectAsync0(() {})); provider .didPushRouteInformation(RouteInformation(uri: Uri.parse(newRoute))); @@ -41,6 +43,7 @@ void main() { late final GoRouteInformationProvider provider = GoRouteInformationProvider( initialLocation: initialRoute, initialExtra: null); + addTearDown(provider.dispose); provider.addListener(expectAsync0(() {})); provider.didPushRouteInformation( RouteInformation(uri: Uri.parse(expectedUriString))); @@ -60,6 +63,7 @@ void main() { late final GoRouteInformationProvider provider = GoRouteInformationProvider( initialLocation: initialRoute, initialExtra: null); + addTearDown(provider.dispose); provider.addListener(expectAsync0(() {})); provider.didPushRouteInformation( RouteInformation(uri: Uri.parse(expectedUriString))); @@ -78,6 +82,7 @@ void main() { initialLocation: initialRoute, initialExtra: null, routerNeglect: true); + addTearDown(provider.dispose); provider.addListener(expectAsync0(() {})); provider.go(newRoute); provider.routerReportsNewRouteInformation( @@ -94,6 +99,7 @@ void main() { late final GoRouteInformationProvider provider = GoRouteInformationProvider( initialLocation: initialRoute, initialExtra: null); + addTearDown(provider.dispose); provider.addListener(expectAsync0(() {})); provider.go(newRoute); provider.routerReportsNewRouteInformation( diff --git a/script/configs/allowed_unpinned_deps.yaml b/script/configs/allowed_unpinned_deps.yaml index 8941007dfa12..9aa33fd59f8e 100644 --- a/script/configs/allowed_unpinned_deps.yaml +++ b/script/configs/allowed_unpinned_deps.yaml @@ -45,6 +45,7 @@ - io - js - json_serializable +- leak_tracker_flutter_testing - lints - logging - markdown