GetX Navigation
Priority: P0 (CRITICAL)
Decoupled navigation system allowing UI transitions without BuildContext.
Guidelines
- Named Routes: Use
Get.toNamed('/path'). Define routes inAppPages. - Navigation APIs:
Get.to(): Push new route.Get.off(): Replace current route.Get.offAll(): Clear stack and push.Get.back(): Pop route/dialog/bottomSheet.
- Bindings: Link routes with
Bindingsfor automated lifecycle. - Middleware: Implement
GetMiddlewarefor Auth/Permission guards.
Code Example
static final routes = [
GetPage(
name: _Paths.HOME,
page: () => HomeView(),
binding: HomeBinding(),
middlewares: [AuthMiddleware()],
),
];
// Usage in Controller
void logout() => Get.offAllNamed(Routes.LOGIN);
Anti-Patterns
- Navigator Context: Do not use
Navigator.of(context)with GetX. - Hardcoded Routes: Use a
Routesconstant class. - Direct Dialogs: Use
Get.dialog()andGet.snackbar().
References
Related Topics
getx-state-management | feature-based-clean-architecture