urlPath static method

String urlPath()

Returns the url path if any Returns an empty string otherwise.

Implementation

static String urlPath() {
  String? path;
  try {
    // I get an 'Operand of null-aware' error otherwise. Strange.
    path = window.location.pathname;
  } catch (ex) {
    path = null;
  }
  return path ?? '';
}