[web] Always send the route name even if it's null (#41996)

diff --git a/packages/flutter/lib/src/widgets/route_notification_messages.dart b/packages/flutter/lib/src/widgets/route_notification_messages.dart
index 5cbe6bd..4b82a73 100644
--- a/packages/flutter/lib/src/widgets/route_notification_messages.dart
+++ b/packages/flutter/lib/src/widgets/route_notification_messages.dart
@@ -29,14 +29,12 @@
   static void _notifyRouteChange(String methodName, Route<dynamic> route, Route<dynamic> previousRoute) {
     final String previousRouteName = previousRoute?.settings?.name;
     final String routeName = route?.settings?.name;
-    if (previousRouteName != null || routeName != null) {
-      SystemChannels.navigation.invokeMethod<void>(
-        methodName,
-        <String, dynamic>{
-          'previousRouteName': previousRouteName,
-          'routeName': routeName,
-        },
-      );
-    }
+    SystemChannels.navigation.invokeMethod<void>(
+      methodName,
+      <String, dynamic>{
+        'previousRouteName': previousRouteName,
+        'routeName': routeName,
+      },
+    );
   }
 }
diff --git a/packages/flutter/test/widgets/route_notification_messages_test.dart b/packages/flutter/test/widgets/route_notification_messages_test.dart
index c8f9d39..8a7dee5 100644
--- a/packages/flutter/test/widgets/route_notification_messages_test.dart
+++ b/packages/flutter/test/widgets/route_notification_messages_test.dart
@@ -167,4 +167,51 @@
           },
         ));
   });
+
+  testWidgets('Nameless routes should send platform messages', (WidgetTester tester) async {
+    final List<MethodCall> log = <MethodCall>[];
+    SystemChannels.navigation.setMockMethodCallHandler((MethodCall methodCall) async {
+      log.add(methodCall);
+    });
+
+    await tester.pumpWidget(MaterialApp(
+      initialRoute: '/home',
+      routes: <String, WidgetBuilder>{
+        '/home': (BuildContext context) {
+          return OnTapPage(
+            id: 'Home',
+            onTap: () {
+              // Create a route with no name.
+              final Route<void> route = MaterialPageRoute<void>(
+                builder: (BuildContext context) => const Text('Nameless Route'),
+              );
+              Navigator.push<void>(context, route);
+            },
+          );
+        },
+      },
+    ));
+
+    expect(log, hasLength(1));
+    expect(
+      log.last,
+      isMethodCall('routePushed', arguments: <String, dynamic>{
+        'previousRouteName': null,
+        'routeName': '/home',
+      }),
+    );
+
+    await tester.tap(find.text('Home'));
+    await tester.pump();
+    await tester.pump(const Duration(seconds: 1));
+
+    expect(log, hasLength(2));
+    expect(
+      log.last,
+      isMethodCall('routePushed', arguments: <String, dynamic>{
+        'previousRouteName': '/home',
+        'routeName': null,
+      }),
+    );
+  });
 }