Returns a Uri that differs from this only in not having a fragment.

If this Uri does not have a fragment, it is itself returned.

Source

Uri removeFragment() {
  if (!this.hasFragment) return this;
  return new Uri._internal(scheme, userInfo, host, port, path, query, null);
}