pushUri method
void
pushUri(
- Uri uri, {
- RouteState<
Object?> ? errorFallback, - AnimationEffect forwardAnimationEffect = const NoEffect(),
- AnimationEffect backwardAnimationEffect = const NoEffect(),
Implementation
void pushUri(
Uri uri, {
RouteState<Object?>? errorFallback,
AnimationEffect forwardAnimationEffect = const NoEffect(),
AnimationEffect backwardAnimationEffect = const NoEffect(),
}) {
// If [uri] is a stack-encoded URL (path contains `+`), treat it as a
// multi-route push: decode into segments and append all of them above
// the current top, running a single transition into the new topmost
// route. Lets callers do `controller.pushUri(Uri.parse('/sheet+/dialog'))`
// and end up with both routes added in one call.
if (RouteStackUri.isStacked(uri)) {
_pushStack(
RouteStackUri.decode(uri),
errorFallback: errorFallback,
animationEffect: forwardAnimationEffect,
);
return;
}
final state = _pNavigationState.getValue();
final indexInHistory = state.routes.indexWhere(
(r) => _urisMatch(r.uri, uri),
);
if (indexInHistory == state.index) return;
if (indexInHistory != -1) {
final didGo = go(
indexInHistory,
forwardAnimationEffect: forwardAnimationEffect,
backwardAnimationEffect: backwardAnimationEffect,
);
if (!didGo && errorFallback != null) {
push(
errorFallback,
errorFallback: errorFallback,
animationEffect: forwardAnimationEffect,
);
}
} else {
push(
RouteState(uri),
errorFallback: errorFallback,
animationEffect: forwardAnimationEffect,
);
}
}