updateParams method
It requests the Browser to update its address bar based on the given params.
Example, given a route templated configured as '/dynamic_url_example{?tab}'
,
the following generates: "baseURL?tab=books" or "baseURL?tab=authors".
final aps = APSNavigator.of(context);
aps.updateParams(
params: {'tab': index == 0 ? 'books' : 'authors'},
);
Implementation
void updateParams({required Map<String, dynamic> params}) {
final desc = currentSnapshot.topConfiguration;
final showsQueriesOnLocation = desc.location.contains('?');
final plainLocation = Helpers.locationWithoutQueries(desc.location);
final descriptorToAdd = desc.copyWith(
values: params,
location: showsQueriesOnLocation
? Helpers.mergeLocationAndQueries(plainLocation, params)
: desc.location,
);
currentSnapshot.routesDescriptors.removeLast();
currentSnapshot.routesDescriptors.add(descriptorToAdd);
_forceBrowserUpdateURL();
}