replace method

Future<void> replace(
  1. Object location
)

Implementation

Future<void> replace(Object location) {
  return _enqueueNavigation<void>(() async {
    final from = controller.state.location;
    final startedAt = DateTime.now();
    final before = controller.state;
    final targetLocation = _locationFrom(location);
    await _replaceNow(targetLocation);
    final changed = !identical(before, controller.state);
    if (changed) {
      _emitNavigationEvent(
        type: LmNavigationEventType.navigateCommit,
        source: LmNavigationSource.programmaticReplace,
        from: from,
        to: controller.state.location,
        result: LmNavigationResult.committed,
        startedAt: startedAt,
      );
    }
    return _NavigationOutcome<void>(
      null,
      changed ? _forwardDurationForLocation(targetLocation) : Duration.zero,
    );
  });
}