Repository: flutter
Issue: [web] Missing route state on refresh
Labels: c: new feature,framework,platform-web,c: proposal,P3,team-web,triaged-web

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Use case

Maintaining route state is achievable using `RouterDelegate.currentConfiguration` and `RouteInformationParser.restoreRouteInformation`, functioning as intended. On the web, during backward or forward navigation, `RouteInformationParser.parseRouteInformation` correctly interprets both state and location. However, upon refreshing the app (e.g., pressing F5 or returning after navigating to another webpage), the current location is detected, but the state is missed.

This issue arises from the uninitialized state parameter in the default route information provider:
https://github.com/flutter/flutter/blob/6b3eefc2868b8cda1728a9784acdf0b8336ac5ae/packages/flutter/lib/src/widgets/app.dart#L1366-L1372

Current behavior when refreshing the app:

https://github.com/flutter/flutter/assets/8436039/693ed465-dc03-4b32-a60a-7b9a39437257

Example code:

```dart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_web_plugins/url_strategy.dart';

void main() {
  usePathUrlStrategy();

  runApp(const MyApp());
}

class MyRouteParser extends RouteInformationParser<RouteInformation> {
  const MyRouteParser();

  @override
  RouteInformation restoreRouteInformation(RouteInformation configuration) => configuration;

  @override
  Future<RouteInformation> parseRouteInformation(RouteInformation routeInformation) {
    print('URL: ${routeInformation.location}');
    print('State: ${routeInformation.state}');

    return SynchronousFuture(routeInformation);
  }
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final routerDelegate = MyRouterDelegate();

  @override
  void dispose() {
    routerDelegate.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      title: 'Router state test',
      routerDelegate: routerDelegate,
      routeInformationParser: const MyRouteParser(),
    );
  }
}

class MyRouterDelegate extends RouterDelegate<RouteInformation> with ChangeNotifier {
  RouteInformation? configuration;

  @override
  Widget build(BuildContext context) {
    return Navigator(
      pages: [
        MaterialPage(
          child: MyScreen(
            configuration: configuration,
          ),
        ),
      ],
      onPopPage: (_, __) => false,
    );
  }

  void refresh() => notifyListeners();

  @override
  Future<bool> popRoute() => SynchronousFuture<bool>(true);

  @override
  Future<void> setNewRoutePath(RouteInformation configuration) {
    this.configuration = configuration;
    return SynchronousFuture<void>(null);
  }

  @override
  RouteInformation get currentConfiguration {
    final state = {'test': DateTime.now().millisecondsSinceEpoch};
    print('Setting state: $state');

    return RouteInformation(location: '/', state: state);
  }
}

class MyScreen extends StatelessWidget {
  const MyScreen({
    super.key,
    required this.configuration,
  });

  final RouteInformation? configuration;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text('URL: ${configuration?.location}'),
            const SizedBox(height: 8),
            Text('State: ${configuration?.state}'),
          ],
        ),
      ),
    );
  }
}
```

### Proposal

For a more consistent web routing experience, integrate the default route state alongside the location and pass it to `PlatformRouteInformationProvider`.

```dart
RouteInformation(
    location: WidgetsBinding.instance.platformDispatcher.defaultRouteName,
    state: WidgetsBinding.instance.platformDispatcher.defaultRouteState
)
```