getx icon indicating copy to clipboard operation
getx copied to clipboard

How to refresh the previous page when Get.back and Get.until

Open magic3584 opened this issue 1 year ago • 7 comments
trafficstars

When using Get.to to push from A to B, how can I refresh A when pop form B? I cannot find any solution like this? Is there any solution like viewWillAppear in iOS?

magic3584 avatar Mar 01 '24 11:03 magic3584

A Page onTap:() async { var res = await Get.to(() => B()); // refresh A Page if (res != null && res == true) controller.refresh();

}

pennyfine avatar Mar 04 '24 03:03 pennyfine

kindly give proper example cant understand

fisforfaheem avatar Mar 04 '24 19:03 fisforfaheem

kindly give proper example cant understand

Future goToAnotherPage() async { var response = await Get.toNamed( AppRoutes.anotherPage, arguments: { 'argument': 'myArgument', }, );

// It will be executed only after you Get.back() from anotherPage. if (response != null) { // do something } }

I hope I have helped you @fisforfaheem =)

ssthiago avatar Mar 05 '24 13:03 ssthiago

@pennyfine @ssthiago Thanks guys, it works perfectly when using Get.back()! But I have a more in-depth question: can I refresh when pop from deeper stack such as when route is A->B->C->D, make A refresh when pop from D directly using Get.until?

magic3584 avatar Mar 09 '24 14:03 magic3584

maybe this helps: https://stackoverflow.com/questions/66272880/flutter-how-to-automatically-trigger-a-function-when-a-route-was-pushed-on-to-t

DevTello avatar Mar 19 '24 07:03 DevTello

@magic3584 for now you need to nest the Get.back(result: true). means in B-C-D all is calling Get.back(result: true) until it reaches A and in A u can refresh like the above answer..

RahnRazamai avatar Mar 27 '24 13:03 RahnRazamai

I found another problem: It's not called when popped by swipe left to right. @pennyfine @ssthiago

magic3584 avatar Jun 24 '24 06:06 magic3584