asyncNavigationCallback property
An AsyncCallback used to perform some operations asynchronously. E.g. Loading data from server before moving to next screen. Do not use duration while using asyncCallback. It just doesn't make sense.
asyncCallback: () async {
String? token = await CredentialStore.getBrearerToken();
if (token != null && token.isNotEmpty) {
await getHomeScreenData();
GoRouter.of(context).goNamed("home");
OR
Navigator.pushReplacementNamed(context, "home");
} else {
GoRouter.of(context).goNamed("/");
OR
Navigator.pushReplacementNamed(context, "/");
}
}
Implementation
AsyncCallback? asyncNavigationCallback;