Get.ToNamed using same controller and page?

108 Views Asked by At

I have a Product detail page, with the necessary controller and binding. The controller will receive a parameter,that is the product reference, so that onInit it can be used to make an API call. While on the page, i have related products. This products can be tapped, and onTap, i was redirecting the user, but it needs to be a page of the same class and controller. For that i did this:

                                child: InkWell(
                                  onTap: (){
                                    // onTap will redirect to product details
                                    Get.toNamed(
                                      AppRoutes.artigodetalhe,
                                      preventDuplicates: false,
                                      parameters: {
                                        'codProduto': artigo.referencia,
                                      },
                                    );
                                  },

This results on the same page being instantiated abd pushed to the stack, but its a copy of the first one, since it does not instantiante a new controller, or re-instantiate. Im still able to pop/go back.

If i use the Get.OffNamed, it will sort of do what i wanted, pops the page from stack. I do not know what im failing to understand, and if it might be because im using lazyPut on the Binding. Got the preventDuplicates on the toNamed method, and also no success. Also, i have seen similar questions, and one where it was mentioned to use phenix on the lazyPut, but i failed to understand that.

1

There are 1 best solutions below

0
On

you can use to recreate controller

    Get.lazyPut(() => RealTimeController(),fenix: true);