setQuery method

Future<void> setQuery(
  1. Map<String, dynamic> query, {
  2. bool replace = false,
})

Updates the query parameters on the current path, either pushing or replacing history.

When replace is true, uses replace; otherwise uses navigate. Retains the current pathname and any existing hash fragment.

await controller.setQuery({'filter': 'active'}, replace: true);

Implementation

Future<void> setQuery(Map<String, dynamic> query, {bool replace = false}) async {
  final qs = buildQueryString(query);
  final frag = currentFragment.value.isNotEmpty ? '#${currentFragment.value}' : '';
  final target = '${currentPath.value}$qs$frag';
  if (replace) {
    await this.replace(target);
  } else {
    await navigate(target);
  }
}