replace method

  1. @override
void replace(
  1. Uri uri, [
  2. Object? state
])
override

Replaces the current history entry.

The optional state is stored on the entry and can be read back via location's RouteInformation.state.

Implementation

@override
void replace(Uri uri, [Object? state]) {
  action = .replace;
  index = this.state?.index ?? 0;
  final historyState = _HistoryState(
    identifier: this.state?.identifier ?? generateIdentifier(),
    index: index,
    userData: state,
  );

  window.history.replaceState(
    historyState.toJson().jsify(),
    '',
    createHref(uri),
  );
}