2

Before I back to the previous screen, is it possible to get this back name and conditional execute the needed method call?

ccd
  • 5,788
  • 10
  • 46
  • 96

1 Answers1

1

if you use Get, you can get previous route name directly by Get.previousRoute.

It implements this by a NavigatorObserver (lib/get_navigation/src/routes/observers/route_observer.dart)(https://api.flutter.dev/flutter/widgets/NavigatorObserver-class.html). You can also implement your own observer and maintain the route history.

Spike L
  • 404
  • 2
  • 10
  • Could show a example code how to pass arguments to the specific back screen? – ccd Sep 23 '21 at 10:29
  • I assume you are using getx. At first screen, use `final YOUR_RESULT = await Get.toNamed(page);` to get the result. At second screen, use `Get.back(YOUR_RESULT);` to pass the result to previous screen. – Spike L Sep 24 '21 at 06:20