goBranch method

void goBranch(
  1. int index, {
  2. bool initialLocation = false,
})

Navigate to the last location of the StatefulShellBranch at the provided index in the associated StatefulShellBranch.

This method will switch the currently active branch Navigator for the StatefulShellRoute. If the branch has not been visited before, or if initialLocation is true, this method will navigate to initial location of the branch (see StatefulShellBranch.initialLocation).

Implementation

void goBranch(int index, {bool initialLocation = false}) {
  assert(index >= 0 && index < route.branches.length);
  final RouteMatchList? matchList =
      initialLocation ? null : _matchListForBranch(index);
  if (matchList != null && matchList.isNotEmpty) {
    _router.restore(matchList);
  } else {
    _router.go(widget._effectiveInitialBranchLocation(index));
  }
}