browserSetNewConfiguration method
Configures this ApsController
instance to use an ApsSnapshot
created based on the given configuration
.
configuration
is usually an ApsParserData that was created by the browser or recovered from its history.
Implementation
void browserSetNewConfiguration(ApsParserData configuration) {
if (configuration.location == '/') {
backToRoot();
return;
}
if (configuration.hasPageDescriptorsAvailableFromWebHistory) {
// load all descriptors and create a new Snapshot from them
final descriptors = configuration.descriptorsJsons
.map((j) => ApsRouteDescriptor.fromJson(j))
.toList();
currentSnapshot = ApsSnapshot(
routesDescriptors: descriptors,
popWasRestored: true,
);
notifyListeners();
} else {
// build a new descriptor and upate the current Snapshot
final location = configuration.location;
final template = routerMatcher.getTemplateForRoute(location)!;
final params = routerMatcher.getValuesFromRoute(location);
final descriptorToAdd = ApsRouteDescriptor(
location: location,
template: template,
values: params,
);
currentSnapshot.routesDescriptors.add(descriptorToAdd);
currentSnapshot.popWasRestored =
configuration.isUserOpeningAppForTheFirstTime;
notifyListeners();
}
}