update method

void update({
  1. T? state,
  2. T? popState,
  3. TransitionDelegate? transitionDelegate,
  4. bool beamBackOnPop = false,
  5. bool popBeamLocationOnPop = false,
  6. bool stacked = true,
  7. bool replaceCurrent = false,
  8. bool buildBeamLocation = true,
  9. bool rebuild = true,
  10. bool updateParent = true,
})

Main method to update the state of this; Beamer.of(context),

This "top-level" update is generally used for navigation between BeamLocations and not within a specific BeamLocation. For latter purpose, see BeamLocation.update. Nevertheless, update will work for navigation within BeamLocation. Calling update will run the locationBuilder.

Beamer.of(context).update(
  state: BeamState.fromUriString('/xx'),
);

beamTo and beamToNamed call update to really do the update.

transitionDelegate determines how a new stack of pages replaces current. See Navigator.transitionDelegate.

If beamBackOnPop is set to true, default pop action will triger beamBack instead.

popState is more general than beamBackOnPop, and can beam you anywhere; whatever it resolves to during build.

If stacked is set to false, only the location's last page will be shown.

If replaceCurrent is set to true, new location will replace the last one in the stack.

If rebuild is set to false, build will not occur, but state and browser URL will be updated.

Implementation

void update({
  T? state,
  T? popState,
  TransitionDelegate? transitionDelegate,
  bool beamBackOnPop = false,
  bool popBeamLocationOnPop = false,
  bool stacked = true,
  bool replaceCurrent = false,
  bool buildBeamLocation = true,
  bool rebuild = true,
  bool updateParent = true,
}) {
  active = true;
  _popState = popState ?? _popState;
  _currentTransitionDelegate = transitionDelegate ?? this.transitionDelegate;
  _beamBackOnPop = beamBackOnPop;
  _popBeamLocationOnPop = popBeamLocationOnPop;
  _stacked = stacked;

  if (state != null) {
    this.state = state;
    if (buildBeamLocation) {
      final location = locationBuilder(this.state);
      _pushHistory(location, replaceCurrent: replaceCurrent);
    }
    listener?.call(this.state, _currentBeamLocation);
  }

  if (this.updateParent && updateParent && state != _parent?.state) {
    _parent?.update(
      state: this.state,
      rebuild: false,
    );
  }

  if (!rebuild || !updateParent) {
    updateRouteInformation(this.state);
  }

  if (rebuild) {
    notifyListeners();
  }
}