toPopped method

AppRouteState? toPopped()

Returns a copy of the app route state but with the current route popped.

If a parent route could be determined, then it will be set as the current route. Otherwise, if there is a non-null current, the current route will be set to null.

Returns null if the app route state cannot be popped.

Implementation

AppRouteState? toPopped() {
  final appRoute = appRoutes[appRootRoute] ?? AppRoute.fleet;
  final currentRoute = current ?? appRoute;
  final parent = _getParent(currentRoute);

  if (parent != null) {
    return withCurrentRoute(parent);
  } else if (current != null) {
    return withCurrentRoute(appRoute);
  }

  return null;
}