redirect method
- BuildContext context,
- GoRouterState state
override
An optional redirect function for this route.
Subclasses must override one of build, buildPage, or redirect.
Corresponds to GoRoute.redirect.
Implementation
@override
FutureOr<String?> redirect(BuildContext context, GoRouterState state) async {
if (edit != true) return null;
// If user attempts to edit, check if the user is an admin
final user = ProviderScope.containerOf(context).read(currentUserProvider)!;
// If the user is not an admin, return to the post
return (user.customClaims.admin) ? null : EventRoute(id: id).location;
}