remove static method

void remove(
  1. String key
)

Remove a query parameter.

This method will trigger the onChange event.

Implementation

static void remove(String key) {
  var query = window.location.search;
  var queryObject = query
      .split("&")
      .map((e) {
        final parts = e.split("=");
        return parts[0].replaceAll("?", "") == key ? null : e;
      })
      .where((e) => e != null)
      .join("&");

  window.history.pushState(
    null,
    '',
    queryObject.isEmpty ? '/' : '?$queryObject',
  );
}