Incular logoIncular
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

TypePurpose
RouteInformationNormalized location + optional JSON state; new / with_state / location / uri / state / to_json / from_json
MemoryRouteInformationProviderDeterministic provider; new / root / push / reports
StringRouteInformationParserIdentity location parser
ClosureRouteInformationParserClosure-backed typed parser
normalize_route_locationTrim, leading /, keep ?/#

RouteInformationReportingType: None (default) / Neglect / Navigate. RouteInformationListener / RouteInformationSubscription keep provider callbacks alive.

Delegates and config

TypePurpose
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
RouterDataAmbient { current_route, can_pop, revision } above the delegate
RouterErrorProvider / Parse / Delegate / Restoration / InvalidConfiguration
RouterDelegateListener / RouterDelegateSubscriptionRetained delegate observer handle

NavigationNotification { kind, route_information, can_handle_pop, error } kinds: RouteInformationChanged / DelegateChanged / Restored / BackHandled / BackUnhandled / ParseFailed.

Related: WidgetsApp, Route & Page.

On this page