goStackInBranch method
Implementation
LmNavigationTransaction goStackInBranch(
String branchId,
List<LmRouteNode> routes,
) {
_clearSuppressedSystemBack();
if (routes.isEmpty) {
throw ArgumentError.value(routes, 'routes', 'Stack cannot be empty.');
}
final branch = _state.branches[branchId];
if (branch == null) {
throw StateError('Branch $branchId does not exist.');
}
final locationRoute = routes.last;
final transaction = _transaction(
LmNavigationSource.programmaticGo,
locationRoute,
);
if (_state.modalStack.isEmpty &&
_state.activeBranchId == branchId &&
_isSameStack(branch.semanticStack, routes)) {
return transaction;
}
_commit(
_state.copyWith(
activeBranchId: branchId,
branches: {
..._state.branches,
branchId: branch.copyWith(semanticStack: routes),
},
location: locationRoute.location,
modalStack: const [],
),
);
return transaction;
}