diff --git a/packages/go_router/example/test/path_and_query_params_test.dart b/packages/go_router/example/test/path_and_query_params_test.dart index b59c8c844077..e4af48b7baee 100644 --- a/packages/go_router/example/test/path_and_query_params_test.dart +++ b/packages/go_router/example/test/path_and_query_params_test.dart @@ -18,7 +18,7 @@ void main() { ByteData message = const JSONMethodCodec().encodeMethodCall( MethodCall('pushRouteInformation', testRouteInformation), ); - await ServicesBinding.instance.defaultBinaryMessenger + await tester.binding.defaultBinaryMessenger .handlePlatformMessage('flutter/navigation', message, (_) {}); await tester.pumpAndSettle(); @@ -34,7 +34,7 @@ void main() { message = const JSONMethodCodec().encodeMethodCall( MethodCall('pushRouteInformation', testRouteInformation), ); - await ServicesBinding.instance.defaultBinaryMessenger + await tester.binding.defaultBinaryMessenger .handlePlatformMessage('flutter/navigation', message, (_) {}); await tester.pumpAndSettle(); diff --git a/packages/go_router/example/test/redirection_test.dart b/packages/go_router/example/test/redirection_test.dart index 21a366eaa628..2d0e286ed3b9 100644 --- a/packages/go_router/example/test/redirection_test.dart +++ b/packages/go_router/example/test/redirection_test.dart @@ -19,7 +19,7 @@ void main() { ByteData message = const JSONMethodCodec().encodeMethodCall( MethodCall('pushRouteInformation', testRouteInformation), ); - await ServicesBinding.instance.defaultBinaryMessenger + await tester.binding.defaultBinaryMessenger .handlePlatformMessage('flutter/navigation', message, (_) {}); await tester.pumpAndSettle(); @@ -36,7 +36,7 @@ void main() { message = const JSONMethodCodec().encodeMethodCall( MethodCall('pushRouteInformation', testRouteInformation), ); - await ServicesBinding.instance.defaultBinaryMessenger + await tester.binding.defaultBinaryMessenger .handlePlatformMessage('flutter/navigation', message, (_) {}); await tester.pumpAndSettle(); diff --git a/packages/go_router/test/go_router_test.dart b/packages/go_router/test/go_router_test.dart index 833c16e0fb7d..271ac0f310ca 100644 --- a/packages/go_router/test/go_router_test.dart +++ b/packages/go_router/test/go_router_test.dart @@ -21,14 +21,14 @@ import 'test_helpers.dart'; const bool enableLogs = false; final Logger log = Logger('GoRouter tests'); -Future sendPlatformUrl(String url) async { +Future sendPlatformUrl(String url, WidgetTester tester) async { final Map testRouteInformation = { 'location': url, }; final ByteData message = const JSONMethodCodec().encodeMethodCall( MethodCall('pushRouteInformation', testRouteInformation), ); - await ServicesBinding.instance.defaultBinaryMessenger + await tester.binding.defaultBinaryMessenger .handlePlatformMessage('flutter/navigation', message, (_) {}); } @@ -1495,7 +1495,7 @@ void main() { redirected = false; // Directly set the url through platform message. - await sendPlatformUrl('/dummy'); + await sendPlatformUrl('/dummy', tester); await tester.pumpAndSettle(); expect(router.location, '/login'); @@ -1528,7 +1528,7 @@ void main() { expect(router.location, '/'); // Directly set the url through platform message. - await sendPlatformUrl('/dummy'); + await sendPlatformUrl('/dummy', tester); await tester.pumpAndSettle(); expect(router.location, '/dummy'); }); @@ -1631,7 +1631,7 @@ void main() { }); redirected = false; // Directly set the url through platform message. - await sendPlatformUrl('/dummy'); + await sendPlatformUrl('/dummy', tester); await tester.pumpAndSettle(); expect(router.location, '/login'); @@ -2024,7 +2024,7 @@ void main() { final GoRouter router = await createRouter(routes, tester); // Directly set the url through platform message. - await sendPlatformUrl('/dummy/dummy2'); + await sendPlatformUrl('/dummy/dummy2', tester); await tester.pumpAndSettle(); expect(router.location, '/other');