Navigator & Routes
Stack navigation, pages, overlays, dialogs, and pop scopes with every method.
Cloneable stack with imperative, declarative (set_pages), and restorable
driving.
| Method | Effect |
|---|---|
new() | Empty stack |
push(route) / push_page(page) | Push, returns RouteId |
set_pages(pages) | Keyed reconcile; errors on duplicate keys |
maybe_pop() | Popped / Blocked / Empty |
pop() / replace(route) | Remove or swap top |
current() / routes() / revision() | Inspection |
can_pop() | len > 1 |
observe(f) | Subscribe to push/pop/replace events |
set_pop_guard(f) | Veto pops per route |
Navigator
use incular::prelude::*;
fn main() {
let nav = Navigator::new();
nav.set_pop_guard(|_route| PopDecision::Allow);
let routes = nav.routes().len();
let revision = nav.revision();
nav.clear_pop_guard();
let app = Application::new(move |_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(Text::new(format!(
"routes: {routes}, rev: {revision}, pop: {}",
nav.can_pop()
)))
.build()
.into()
})
.expect("valid application");
incular::run(app).expect("run application");
}PopDecision: Allow / Deny.
Routes and pages
Route / RouteSettings / RouteTransition / RoutePresentation (stack vs
overlay hosts) / RouteResult / RestorableRoute / Page /
PageRouteBuilder. Overlay / OverlayEntry for imperative overlay content.
use incular::prelude::*;
fn main() {
let page = Page::new("home", Text::new("Home"));
println!("page: {}", page.name);
let app = Application::new(|_cx| Text::new("Hi").into())
.expect("valid application");
incular::run(app).expect("run application");
}Dialogs and sheets
use incular::prelude::*;
fn main() {
let app = Application::new(|_cx| {
Text::new("Dialog content").into()
})
.expect("valid application");
incular::run(app).expect("run application");
}Snapshots and notifications: NavigatorSnapshot { format_version, routes, active_route } with NAVIGATOR_SNAPSHOT_FORMAT_VERSION = 1;
NavigationNotification { kind, route_information, can_handle_pop, error }
kinds RouteInformationChanged / DelegateChanged / Restored /
BackHandled / BackUnhandled / ParseFailed
(NavigationNotificationSubscription keeps listeners alive).
NavigationEvent: pushed / popped / replaced / active-route-changed;
NavigationNotificationKind / NavigationNotificationListener complete the
observer vocabulary.
BackButtonDispatcher reports handled, depth, blocked, pop.
AnimatedModalBarrier takes color animation, dismissible, and semantics
label.
Related: Overlay,
Restoration.