@@ -40,7 +40,7 @@ void main() {
4040 expect (find.widgetWithText (Navigator , 'foo' ), findsOneWidget);
4141 });
4242
43- testWidgets ('Has default cupertino localizations' , (WidgetTester tester) async {
43+ testWidgetsWithLeakTracking ('Has default cupertino localizations' , (WidgetTester tester) async {
4444 await tester.pumpWidget (
4545 CupertinoApp (
4646 home: Builder (
@@ -62,7 +62,7 @@ void main() {
6262 expect (find.text ('Thu Oct 4 ' ), findsOneWidget);
6363 });
6464
65- testWidgets ('Can use dynamic color' , (WidgetTester tester) async {
65+ testWidgetsWithLeakTracking ('Can use dynamic color' , (WidgetTester tester) async {
6666 const CupertinoDynamicColor dynamicColor = CupertinoDynamicColor .withBrightness (
6767 color: Color (0xFF000000 ),
6868 darkColor: Color (0xFF000001 ),
@@ -84,7 +84,7 @@ void main() {
8484 expect (tester.widget <Title >(find.byType (Title )).color.value, 0xFF000001 );
8585 });
8686
87- testWidgets ('Can customize initial routes' , (WidgetTester tester) async {
87+ testWidgetsWithLeakTracking ('Can customize initial routes' , (WidgetTester tester) async {
8888 final GlobalKey <NavigatorState > navigatorKey = GlobalKey <NavigatorState >();
8989 await tester.pumpWidget (
9090 CupertinoApp (
@@ -131,7 +131,7 @@ void main() {
131131 expect (find.text ('regular page two' ), findsNothing);
132132 });
133133
134- testWidgets ('CupertinoApp.navigatorKey can be updated' , (WidgetTester tester) async {
134+ testWidgetsWithLeakTracking ('CupertinoApp.navigatorKey can be updated' , (WidgetTester tester) async {
135135 final GlobalKey <NavigatorState > key1 = GlobalKey <NavigatorState >();
136136 await tester.pumpWidget (CupertinoApp (
137137 navigatorKey: key1,
@@ -147,12 +147,13 @@ void main() {
147147 expect (key1.currentState, isNull);
148148 });
149149
150- testWidgets ('CupertinoApp.router works' , (WidgetTester tester) async {
150+ testWidgetsWithLeakTracking ('CupertinoApp.router works' , (WidgetTester tester) async {
151151 final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider (
152152 initialRouteInformation: RouteInformation (
153153 uri: Uri .parse ('initial' ),
154154 ),
155155 );
156+ addTearDown (provider.dispose);
156157 final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate (
157158 builder: (BuildContext context, RouteInformation information) {
158159 return Text (information.uri.toString ());
@@ -164,6 +165,7 @@ void main() {
164165 return route.didPop (result);
165166 },
166167 );
168+ addTearDown (delegate.dispose);
167169 await tester.pumpWidget (CupertinoApp .router (
168170 routeInformationProvider: provider,
169171 routeInformationParser: SimpleRouteInformationParser (),
@@ -176,9 +178,14 @@ void main() {
176178 await tester.binding.defaultBinaryMessenger.handlePlatformMessage ('flutter/navigation' , message, (_) { });
177179 await tester.pumpAndSettle ();
178180 expect (find.text ('popped' ), findsOneWidget);
179- });
180-
181- testWidgets ('CupertinoApp.router route information parser is optional' , (WidgetTester tester) async {
181+ },
182+ // TODO(polina-c): remove after fixing
183+ // https://github.com/flutter/flutter/issues/134205
184+ leakTrackingTestConfig: const LeakTrackingTestConfig (
185+ allowAllNotDisposed: true ,
186+ ));
187+
188+ testWidgetsWithLeakTracking ('CupertinoApp.router route information parser is optional' , (WidgetTester tester) async {
182189 final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate (
183190 builder: (BuildContext context, RouteInformation information) {
184191 return Text (information.uri.toString ());
@@ -190,6 +197,7 @@ void main() {
190197 return route.didPop (result);
191198 },
192199 );
200+ addTearDown (delegate.dispose);
193201 delegate.routeInformation = RouteInformation (uri: Uri .parse ('initial' ));
194202 await tester.pumpWidget (CupertinoApp .router (
195203 routerDelegate: delegate,
@@ -201,9 +209,14 @@ void main() {
201209 await tester.binding.defaultBinaryMessenger.handlePlatformMessage ('flutter/navigation' , message, (_) { });
202210 await tester.pumpAndSettle ();
203211 expect (find.text ('popped' ), findsOneWidget);
204- });
205-
206- testWidgets ('CupertinoApp.router throw if route information provider is provided but no route information parser' , (WidgetTester tester) async {
212+ },
213+ // TODO(polina-c): remove after fixing
214+ // https://github.com/flutter/flutter/issues/134205
215+ leakTrackingTestConfig: const LeakTrackingTestConfig (
216+ allowAllNotDisposed: true ,
217+ ));
218+
219+ testWidgetsWithLeakTracking ('CupertinoApp.router throw if route information provider is provided but no route information parser' , (WidgetTester tester) async {
207220 final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate (
208221 builder: (BuildContext context, RouteInformation information) {
209222 return Text (information.uri.toString ());
@@ -215,20 +228,22 @@ void main() {
215228 return route.didPop (result);
216229 },
217230 );
231+ addTearDown (delegate.dispose);
218232 delegate.routeInformation = RouteInformation (uri: Uri .parse ('initial' ));
219233 final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider (
220234 initialRouteInformation: RouteInformation (
221235 uri: Uri .parse ('initial' ),
222236 ),
223237 );
238+ addTearDown (provider.dispose);
224239 await tester.pumpWidget (CupertinoApp .router (
225240 routeInformationProvider: provider,
226241 routerDelegate: delegate,
227242 ));
228243 expect (tester.takeException (), isAssertionError);
229244 });
230245
231- testWidgets ('CupertinoApp.router throw if route configuration is provided along with other delegate' , (WidgetTester tester) async {
246+ testWidgetsWithLeakTracking ('CupertinoApp.router throw if route configuration is provided along with other delegate' , (WidgetTester tester) async {
232247 final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate (
233248 builder: (BuildContext context, RouteInformation information) {
234249 return Text (information.uri.toString ());
@@ -240,6 +255,7 @@ void main() {
240255 return route.didPop (result);
241256 },
242257 );
258+ addTearDown (delegate.dispose);
243259 delegate.routeInformation = RouteInformation (uri: Uri .parse ('initial' ));
244260 final RouterConfig <RouteInformation > routerConfig = RouterConfig <RouteInformation >(routerDelegate: delegate);
245261 await tester.pumpWidget (CupertinoApp .router (
@@ -249,15 +265,19 @@ void main() {
249265 expect (tester.takeException (), isAssertionError);
250266 });
251267
252- testWidgets ('CupertinoApp.router router config works' , (WidgetTester tester) async {
268+ testWidgetsWithLeakTracking ('CupertinoApp.router router config works' , (WidgetTester tester) async {
269+ late SimpleNavigatorRouterDelegate delegate;
270+ addTearDown (() => delegate.dispose ());
271+ final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider (
272+ initialRouteInformation: RouteInformation (
273+ uri: Uri .parse ('initial' ),
274+ ),
275+ );
276+ addTearDown (provider.dispose);
253277 final RouterConfig <RouteInformation > routerConfig = RouterConfig <RouteInformation >(
254- routeInformationProvider: PlatformRouteInformationProvider (
255- initialRouteInformation: RouteInformation (
256- uri: Uri .parse ('initial' ),
257- ),
258- ),
278+ routeInformationProvider: provider,
259279 routeInformationParser: SimpleRouteInformationParser (),
260- routerDelegate: SimpleNavigatorRouterDelegate (
280+ routerDelegate: delegate = SimpleNavigatorRouterDelegate (
261281 builder: (BuildContext context, RouteInformation information) {
262282 return Text (information.uri.toString ());
263283 },
@@ -280,9 +300,14 @@ void main() {
280300 await tester.binding.defaultBinaryMessenger.handlePlatformMessage ('flutter/navigation' , message, (_) { });
281301 await tester.pumpAndSettle ();
282302 expect (find.text ('popped' ), findsOneWidget);
283- });
284-
285- testWidgets ('CupertinoApp has correct default ScrollBehavior' , (WidgetTester tester) async {
303+ },
304+ // TODO(polina-c): remove after fixing
305+ // https://github.com/flutter/flutter/issues/134205
306+ leakTrackingTestConfig: const LeakTrackingTestConfig (
307+ allowAllNotDisposed: true ,
308+ ));
309+
310+ testWidgetsWithLeakTracking ('CupertinoApp has correct default ScrollBehavior' , (WidgetTester tester) async {
286311 late BuildContext capturedContext;
287312 await tester.pumpWidget (
288313 CupertinoApp (
@@ -297,7 +322,7 @@ void main() {
297322 expect (ScrollConfiguration .of (capturedContext).runtimeType, CupertinoScrollBehavior );
298323 });
299324
300- testWidgets ('A ScrollBehavior can be set for CupertinoApp' , (WidgetTester tester) async {
325+ testWidgetsWithLeakTracking ('A ScrollBehavior can be set for CupertinoApp' , (WidgetTester tester) async {
301326 late BuildContext capturedContext;
302327 await tester.pumpWidget (
303328 CupertinoApp (
@@ -315,7 +340,7 @@ void main() {
315340 expect (scrollBehavior.getScrollPhysics (capturedContext).runtimeType, NeverScrollableScrollPhysics );
316341 });
317342
318- testWidgets ('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available' , (WidgetTester tester) async {
343+ testWidgetsWithLeakTracking ('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available' , (WidgetTester tester) async {
319344 late BuildContext capturedContext;
320345 final UniqueKey uniqueKey = UniqueKey ();
321346 await tester.pumpWidget (
@@ -335,7 +360,7 @@ void main() {
335360 expect (capturedContext.dependOnInheritedWidgetOfExactType <MediaQuery >()? .key, uniqueKey);
336361 });
337362
338- testWidgets ('Text color is correctly resolved when CupertinoThemeData.brightness is null' , (WidgetTester tester) async {
363+ testWidgetsWithLeakTracking ('Text color is correctly resolved when CupertinoThemeData.brightness is null' , (WidgetTester tester) async {
339364 debugBrightnessOverride = Brightness .dark;
340365
341366 await tester.pumpWidget (
@@ -374,7 +399,7 @@ void main() {
374399 debugBrightnessOverride = null ;
375400 });
376401
377- testWidgets ('Cursor color is resolved when CupertinoThemeData.brightness is null' , (WidgetTester tester) async {
402+ testWidgetsWithLeakTracking ('Cursor color is resolved when CupertinoThemeData.brightness is null' , (WidgetTester tester) async {
378403 debugBrightnessOverride = Brightness .dark;
379404
380405 RenderEditable findRenderEditable (WidgetTester tester) {
@@ -431,7 +456,7 @@ void main() {
431456 debugBrightnessOverride = null ;
432457 });
433458
434- testWidgets ('Assert in buildScrollbar that controller != null when using it' , (WidgetTester tester) async {
459+ testWidgetsWithLeakTracking ('Assert in buildScrollbar that controller != null when using it' , (WidgetTester tester) async {
435460 const ScrollBehavior defaultBehavior = CupertinoScrollBehavior ();
436461 late BuildContext capturedContext;
437462
0 commit comments