My project is using GetX as state manager and navigator manager. Im trying to create a function for checking current route every 15 second. Here is my code
checkRouteTimer = Timer.periodic(const Duration(seconds: 15), (timer) async {
var route = ModalRoute.of(Get.context!);
if(route!.settings.name == "/first") {
// Execute Function here !!!
}
});
route is null when i using "Get.context" in ModalRoute.of()
I tried using BuildContext from build, but it always remain first route even i go to another route. Can some one help me with this? or there have some better way to check current route every 15 second.
CodePudding user response:
You can use this one in GetX :
Get.currentRoute