getx
getx copied to clipboard
Get.rootDelegate.toNamed should not remove the current page?
At first I use Get.toNamed('/some_page') to get the SomePage. It work fine, my current page is alive, its controller have never been deleted. When I use Get.back() the state stay as it is (scroll location).
I update my app to Nav2.0, and now using Get.rootDelegate.toNamed(Routes.SOME_PAGE), the getx log tell me that its controller is delete. When I pop the new page, the current page's (first page) controller is re-initialize and I lose its state (scroll location reset to 0).
The two toNamed call should not behave differently, isn't it? Is there a way for me to keep the current page alive?
get version and flutter doctor, please
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-arm, locale en)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.59.0)
[✓] Connected device (2 available)
get: ^4.3.8
same but the Get.toNamed is not works with me when I use GetMaterialApp.router, is it works with you?
you can use:
Get.rootDelegate.popRoute();
if you just want pop
I have also encountered this problem. There is too few documentation about GetRouterOutlet.
My app code base has root and home module following the nav2 example. I try to remove the rootfrom modules and from app_pages.dart because I feel like It is not necessary for my app. Somehow the problem gone. Get.rootDelegate.toNamed(Routes.SOME_PAGE) behave exactly like Get.toNamed('/some_page'). All the controllers are no longer deleted and re-initialize between pages. So I'm closing this problem.
My root view
class RootView extends GetView<RootController> {
@override
Widget build(BuildContext context) {
return GetRouterOutlet.builder(
builder: (context, delegate, current) {
return Scaffold(
body: GetRouterOutlet(
initialRoute: Routes.HOME,
// anchorRoute: '/',
// filterPages: (afterAnchor) {
// return afterAnchor.take(1);
// },
),
);
},
);
}
}
My app code base has
rootandhomemodule following the nav2 example. I try to remove therootfrom modules and fromapp_pages.dartbecause I feel like It is not necessary for my app. Somehow the problem gone.Get.rootDelegate.toNamed(Routes.SOME_PAGE)behave exactly likeGet.toNamed('/some_page'). All the controllers are no longer deleted and re-initialize between pages. So I'm closing this problem.
but this will cause tabbar works dose not propertly, such as /home/products, /home/profile will not contain bottom bar.
I had a similar problem just now, not sure if the same or not.
It happened when/while using a showSearch. In the end, the "problem" was having my controller defined in the bindings via lazyPut, without fenix=true. Having this set to true, allows it to be created correctly.
My app code base has
rootandhomemodule following the nav2 example. I try to remove therootfrom modules and fromapp_pages.dartbecause I feel like It is not necessary for my app. Somehow the problem gone.Get.rootDelegate.toNamed(Routes.SOME_PAGE)behave exactly likeGet.toNamed('/some_page'). All the controllers are no longer deleted and re-initialize between pages. So I'm closing this problem.but this will cause tabbar works dose not propertly, such as
/home/products,/home/profilewill not contain bottom bar.
Oh, now I know why I lost the bottom navigation bar. Have you find a way to fix it? Thinking about reopen this issue.
I have read some codes about GetRouterOutlet, It seems impossible to solve this problem due to its implementation.
You can try to use another route management library named Routemaster.
Finally, I gave up nav 2 and continued to use old way.
from iPhone6艹
在 2021年9月7日,23:30,ChauCM @.***> 写道:
My app code base has root and home module following the nav2 example. I try to remove the rootfrom modules and from app_pages.dart because I feel like It is not necessary for my app. Somehow the problem gone. Get.rootDelegate.toNamed(Routes.SOME_PAGE) behave exactly like Get.toNamed('/some_page'). All the controllers are no longer deleted and re-initialize between pages. So I'm closing this problem.
but this will cause tabbar works dose not propertly, such as /home/products, /home/profile will not contain bottom bar.
Oh, now I know why I lost the bottom navigation bar. Have you find a way to fix it? Thinking about reopen this issue.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
I have read some codes about GetRouterOutlet, It seems impossible to solve this problem due to its implementation. You can try to use another route management library named Routemaster. Finally, I gave up nav 2 and continued to use old way. from iPhone6艹 … 在 2021年9月7日,23:30,ChauCM @.***> 写道: My app code base has root and home module following the nav2 example. I try to remove the rootfrom modules and from app_pages.dart because I feel like It is not necessary for my app. Somehow the problem gone. Get.rootDelegate.toNamed(Routes.SOME_PAGE) behave exactly like Get.toNamed('/some_page'). All the controllers are no longer deleted and re-initialize between pages. So I'm closing this problem. but this will cause tabbar works dose not propertly, such as /home/products, /home/profile will not contain bottom bar. Oh, now I know why I lost the bottom navigation bar. Have you find a way to fix it? Thinking about reopen this issue. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Routemaster looks promising, did you try it? How is the compatibility with getx? Why did you not end up using it?
Nav2 implementation completely unusable!
- Zero documentation
- toNamed removes previous page -> no back navigation button, slow back navigation with button
- Wirte route tree, initial routes, route naming is unclear and confusing, example not help in many cases (missing docs?)
Nav2 implementation completely unusable!
* Zero documentation * toNamed removes previous page -> no back navigation button, slow back navigation with button * Wirte route tree, initial routes, route naming is unclear and confusing, example not help in many cases (missing docs?)
A proper documentation on Navigation 2 would be really appreciate @jonataslaw !
After more than one year, I moved from getx to more matured libs just because of its problems with router and nav2
After more than one year, I moved from getx to more matured libs just because of its problems with router and nav2
What do you use now?
After more than one year, I moved from getx to more matured libs just because of its problems with router and nav2
Can you tell me what you use now?
fucking getx does not have any solution for just a back prees on rootDelegate ? @jonataslaw
This might be helpful, a way around
calling .backUntil() method and get back to the first route, then replace the current route
await Get.rootDelegate.backUntil(Routes.SIGNIN);
Get.rootDelegate.offNamed(Routes.MAIN_TABS);
Is this issue resolved? I am also facing same issue. On go to new route it is deleting previous route
Is this issue resolved? I am also facing same issue. On go to new route it is deleting previous route
Get.rootDelegate.offNamed("/route_name);
Is this issue resolved? I am also facing same issue. On go to new route it is deleting previous route
Did you define participatesInRootNavigator as true in some pages?
This will cause the navigator to only retain the pages on the path and not retain the history pages.
Is this issue resolved? I am also facing same issue. On go to new route it is deleting previous route
Did you define
participatesInRootNavigatorastruein some pages? This will cause the navigator to only retain the pages on the path and not retain the history pages.
No I haven't defined