Skip to main content

Navigation

The app uses GoRouter for declarative, type-safe routing.

Route Structure

Routes are typically defined in the main app file or a dedicated router configuration.

Common Routes

  • /welcome - Welcome/landing screen
  • /user-register - Registration
  • /otp-verification - OTP verification
  • /user-profile-setup - Profile setup
  • /user-home - Service seeker home
  • /dashboard - Provider dashboard
  • /profile-setup - Provider profile setup
  • /subscription - Subscription plans

Go to Route

context.go('/dashboard');

Replaces the entire navigation stack.

Push Route

context.push('/job-details');

Adds a new route on top of the stack.

Pop Route

context.pop();

Removes the current route from the stack.

Pop with Result

context.pop('result-data');

Conditional Navigation

Navigate based on authentication state:

if (authProvider.isVerified) {
context.go('/dashboard');
} else {
context.go('/welcome');
}

Deep Linking

GoRouter supports deep linking. Configure routes to handle URLs like:

theplugg://job/12345

Route Guards

Implement route guards to protect routes:

// Example guard
if (!authProvider.isVerified) {
context.go('/welcome');
return;
}

Best Practices

  1. Use named routes for better maintainability
  2. Protect routes that require authentication
  3. Handle navigation errors gracefully
  4. Use go() for top-level navigation, push() for modals/details
  5. Clear navigation stack when logging out