publicPath property

String publicPath

The user-visible path for this route, shown in a browser's address bar.

This is only different from fullPath when using a private route, such as '/products/_secret/page', which will show in an address bar as '/products'; everything after the underscore is cut off.

Private routes are useful for making pages that users cannot navigate to directly by entering a URL. For example, you may want to prevent a user from navigating directly to step two of a wizard, without having first completed step one.

Implementation

String get publicPath {
  if (_publicPath == null) {
    final path = _uri.toString();

    if (_privateSegmentIndex == null) {
      _publicPath = path;
    } else {
      _publicPath = pathContext.joinAll(
        pathContext.split(path).take(_privateSegmentIndex!),
      );
    }
  }

  return _publicPath!;
}