# Migration guide for `RouteInformation.location`

> Deprecation of `RouteInformation.location` and its related APIs.




:::important
These breaking change docs are accurate, as of the release
under which they are published. Over time, the
workarounds described here might become inaccurate.
We don't, in general, keep these breaking change docs up
to date as of each release.

这些破坏性改动文档的准确性仅限于其发布时对应的版本。
随着时间的推移，文档中描述的方案可能会逐渐失效。
通常情况下，我们不会在每次发布新版本时都对这些文档进行同步更新。

The [breaking change index file](/release/breaking-changes)
lists the docs created for each release.

[破坏性改动列表](/release/breaking-changes) 
列出了每个版本的文档。

:::


## Summary

`RouteInformation.location` and related APIs were deprecated
in the favor of `RouteInformation.uri`.

## Context

The [`RouteInformation`][] needs the authority information to
handle mobile deeplinks from different web domains.
The `uri` field was added to `RouteInformation` that captures
the entire deeplink information and route-related parameters
were converted to the full [`Uri`][] format.
This led to deprecation of incompatible APIs.

## Description of change

* The `RouteInformation.location` was replaced by `RouteInformation.uri`.
* The `WidgetBindingObserver.didPushRoute` was deprecated.
* The `location` parameter of `SystemNavigator.routeInformationUpdated` was
  replaced by the newly added `uri` parameter.

## Migration guide

Code before migration:

```dart
const RouteInformation myRoute = RouteInformation(location: '/myroute');
```

Code after migration:

```dart
final RouteInformation myRoute = RouteInformation(uri: Uri.parse('/myroute'));
```

Code before migration:

```dart
final String myPath = myRoute.location;
```

Code after migration:

```dart
final String myPath = myRoute.uri.path;
```

Code before migration:

```dart
class MyObserverState extends State<MyWidget> with WidgetsBindingObserver {
  @override
  Future<bool> didPushRoute(String route) => _handleRoute(route);
}
```

Code after migration:

```dart
class MyObserverState extends State<MyWidget> with WidgetsBindingObserver {
  @override
  Future<bool> didPushRouteInformation(RouteInformation routeInformation) => _handleRoute(
    Uri.decodeComponent(
      Uri(
        path: uri.path.isEmpty ? '/' : uri.path,
        queryParameters: uri.queryParametersAll.isEmpty ? null : uri.queryParametersAll,
        fragment: uri.fragment.isEmpty ? null : uri.fragment,
      ).toString(),
    )
  );
}
```

Code before migration:

```dart
SystemNavigator.routeInformationUpdated(location: '/myLocation');
```

Code after migration:

```dart
SystemNavigator.routeInformationUpdated(uri: Uri.parse('/myLocation'));
```

## Timeline

Landed in version: 3.10.0-13.0.pre<br>
In stable release: 3.13.0

## References

Relevant PRs:

* [PR 119968][]: Implement url support for
  RouteInformation and didPushRouteInformation.

[PR 119968]: https://github.com/flutter/flutter/pull/119968
[`RouteInformation`]: https://api.flutter-io.cn/flutter/widgets/RouteInformation-class.html
[`Uri`]: https://api.flutter-io.cn/flutter/dart-core/Uri-class.html

