33 lines
1.0 KiB
Cheetah
33 lines
1.0 KiB
Cheetah
---
|
|
description: "GetX Navigation conventions for {{PROJECT_NAME}}"
|
|
alwaysApply: true
|
|
---
|
|
|
|
# GetX Navigation — {{PROJECT_NAME}}
|
|
|
|
## Named routes
|
|
```dart
|
|
// app_pages.dart — central route definitions
|
|
abstract class AppPages {
|
|
static const initial = Routes.home;
|
|
static final routes = [
|
|
GetPage(name: Routes.home, page: () => const HomeView(), binding: HomeBinding()),
|
|
GetPage(name: Routes.product, page: () => const ProductView(), binding: ProductBinding()),
|
|
];
|
|
}
|
|
|
|
// Navigate — always use named routes
|
|
Get.toNamed(Routes.product, arguments: product); // push
|
|
Get.offAllNamed(Routes.home); // replace stack
|
|
Get.back(); // pop
|
|
```
|
|
|
|
## Bindings
|
|
- Every route has a `Binding` class that creates and injects dependencies
|
|
- **NEVER** use `Get.put()` in a widget — only in Bindings
|
|
- Use `Get.lazyPut()` for deferred creation
|
|
|
|
## Rules
|
|
- **NEVER** use `Navigator.push/pop`
|
|
- All route strings in `lib/core/routing/routes.dart` as constants
|