restoreRouteInformation method
for use by the Router architecture as part of the RouteInformationParser
Implementation
@override
RouteInformation? restoreRouteInformation(RouteMatchList configuration) {
if (configuration.isEmpty) {
return null;
}
String? location;
if (GoRouter.optionURLReflectsImperativeAPIs &&
(configuration.matches.last is ImperativeRouteMatch ||
configuration.matches.last is ShellRouteMatch)) {
RouteMatchBase route = configuration.matches.last;
while (route is! ImperativeRouteMatch) {
if (route is ShellRouteMatch && route.matches.isNotEmpty) {
route = route.matches.last;
} else {
break;
}
}
if (route case final ImperativeRouteMatch safeRoute) {
location = safeRoute.matches.uri.toString();
}
}
return RouteInformation(
uri: Uri.parse(location ?? configuration.uri.toString()),
state: _routeMatchListCodec.encode(configuration),
);
}