Search code examples
flutterdartflutter-getxflutter-navigation

Get.toNamed not working from bottom sheet / different context


I want to use Get.toNamed from a nested bottom sheet (bottom sheet called from a bottom sheet). However, it is not working. I think it's because the context is different. If I was using Navigator, Navigator.of(context, rootNavigator: true).pushNamed("/route"); this would work. However, in my case, I must use the GetX router because the given route is taking in arguments from Get.arguments. Is there any workaround to make Get.toNamed work?


Solution

  • It's hard to see where the problem is without looking at you code. GetX is just a wrapper around Navigator, so both should work.

    Try

    Get.offAndToNamed<void>()