redirect method Null safety

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

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) => null;