Tutorials

Build the first typed route

Create Destination and Route Definition contracts, mount them, own a Session, and await a typed result.

v0.1.0-dev.2Beginner

Build the first typed route

Install the package and import its public library:

shell
flutter pub add ark_navigation:^0.1.0-dev.2

1. Define intent and result

Create HomeDestination extends NavigationDestination<void> and ProductDestination extends NavigationDestination<bool>. Put validated parameters on the Destination itself.

2. Define pages and URIs

Create one NavigationRouteDefinition per Destination. The pageBuilder receives the typed value. Add a codec when the route must support web URLs, restoration, or platform links.

3. Compose the Graph

Create a root Scope, place routes in a feature Module, and Mount that Module into the root. The Module owns route definitions; the application owns placement.

4. Own the Session

Create a stable Session in initState, pass session.routerConfig to MaterialApp.router, and dispose the Session in dispose().

5. Navigate through the narrow port

dart
final ticket = context.readNavigation.push<bool>(
  const ProductDestination(productId: 'keyboard-42'),
);
await ticket.committed;
final completion = await ticket.completed;

Pop with await context.readNavigation.pop(result: true). The caller receives bool?, not Object? or a value extracted from a map.

ARKTELOS

Purpose-built engineering systems for software that has to hold.