redirect method

  1. @override
RouteSettings? redirect(
  1. String? route
)
override

This function will be called when the page of the called route is being searched for. It take RouteSettings as a result an redirect to the new settings or give it null and there will be no redirecting. {@tool snippet}

GetPage redirect(String route) {
  final authService = Get.find<AuthService>();
  return authService.authed.value ? null : RouteSettings(name: '/login');
}

{@end-tool}

Implementation

@override
RouteSettings? redirect(String? route) {
  // TODO: check API key presence via ConfigService
  // final hasKey = Sint.find<ConfigService>().hasApiKey;
  // if (!hasKey) return const RouteSettings(name: NeomageRouteConstants.onboarding);
  return null;
}