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
Navigation Methods
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
- Use named routes for better maintainability
- Protect routes that require authentication
- Handle navigation errors gracefully
- Use
go()for top-level navigation,push()for modals/details - Clear navigation stack when logging out