API ReferenceApplication
Router
Declarative route information, delegates, and validated configs.
Router<T> is a declarative descriptor owning retained subscriptions after
into_widget; RouterConfig<T> is the validated provider/parser/delegate
bundle.
use incular::prelude::*;
fn main() {
let provider = MemoryRouteInformationProvider::root();
let delegate =
BasicRouterDelegate::new(|| Text::new("Home").into());
let router =
Router::with_provider_parser(delegate, provider, StringRouteInformationParser);
let app = Application::new(move |_cx| router.clone().into_widget())
.expect("valid application");
incular::run(app).expect("run application");
}Route information
| Type | Purpose |
|---|---|
RouteInformation | Normalized location + optional JSON state; new / with_state / location / uri / state / to_json / from_json |
MemoryRouteInformationProvider | Deterministic provider; new / root / push / reports |
StringRouteInformationParser | Identity location parser |
ClosureRouteInformationParser | Closure-backed typed parser |
normalize_route_location | Trim, leading /, keep ?/# |
RouteInformationReportingType: None (default) / Neglect / Navigate.
RouteInformationListener / RouteInformationSubscription keep provider
callbacks alive.
Delegates and config
| Type | Purpose |
|---|---|
RouterDelegate<T> | build, current_configuration, set_new_route_path, pop_route, subscribe |
BasicRouterDelegate<T> | Retained delegate with on_set_new_route_path, on_pop_route, notify |
RouterConfig<T> | new / with_provider_parser / try_from_parts / with_back_button_dispatcher |
RouterData | Ambient { current_route, can_pop, revision } above the delegate |
RouterError | Provider / Parse / Delegate / Restoration / InvalidConfiguration |
RouterDelegateListener / RouterDelegateSubscription | Retained delegate observer handle |
NavigationNotification { kind, route_information, can_handle_pop, error }
kinds: RouteInformationChanged / DelegateChanged / Restored /
BackHandled / BackUnhandled / ParseFailed.
Related: WidgetsApp,
Route & Page.