E-Core

Navigation

Routing and navigation guards for E-Core

Navigation

The Navigation package provides type-safe routing with guards and deep linking support.

Overview

e_core_navigation offers:

  • Type-Safe Routes - Compile-time route safety
  • Route Guards - Authentication and authorization guards
  • Deep Linking - URL-based navigation
  • Nested Navigation - Tab and shell navigation patterns

Installation

dependencies:
  e_core_navigation: ^1.0.0

Key Features

Route Definition

@TypedGoRoute<HomeRoute>(path: '/')
class HomeRoute extends GoRouteData {
  const HomeRoute();

  @override
  Widget build(BuildContext context, GoRouterState state) {
    return const HomeScreen();
  }
}

Route Guards

class AuthGuard extends RouteGuard {
  @override
  Future<String?> canNavigate(BuildContext context, GoRouterState state) async {
    final isAuthenticated = await ref.read(authStateProvider).isAuthenticated;
    if (!isAuthenticated) {
      return '/login';
    }
    return null;
  }
}
// Navigate to a route
context.go(const HomeRoute().location);

// Push a route
context.push(UserRoute(id: userId).location);

Learn More

On this page