ワンクリックで
add-guard
Create and apply route guards in Modugo to protect routes with conditional logic
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Create and apply route guards in Modugo to protect routes with conditional logic
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | add-guard |
| description | Create and apply route guards in Modugo to protect routes with conditional logic |
Guards implement IGuard and decide whether navigation to a route should proceed or redirect.
final class AuthGuard implements IGuard {
@override
FutureOr<String?> canActivate(BuildContext context, GoRouterState state) {
final auth = Modugo.i.get<AuthService>();
if (auth.isAuthenticated) return null; // allow navigation
return '/login'; // redirect
}
}
null to allow navigationString) to redirectasync (Future<String?>)child(
'/dashboard',
builder: (_, _) => const DashboardPage(),
guards: [AuthGuard()],
)
Guards on module() propagate automatically to every route inside the module.
module(
'/admin',
AdminModule(),
guards: [AuthGuard(), AdminRoleGuard()],
)
Guards are evaluated in order. The first one that returns a non-null path stops the chain.
guards: [AuthGuard(), FeatureFlagGuard('admin-panel')]
final class SessionGuard implements IGuard {
@override
Future<String?> canActivate(BuildContext context, GoRouterState state) async {
final session = await Modugo.i.get<SessionService>().validate();
return session.isValid ? null : '/session-expired';
}
}
BuildContext and GoRouterState — access DI via Modugo.i.get<T>() or context.read<T>()canActivate are caught, logged, and rethrown — the navigation is blockedmodule() route applies to all ChildRoute descendants automaticallyCreate a new Modugo module with routes, binds, and imports
Create routes in Modugo using ChildRoute, ModuleRoute, ShellModuleRoute, StatefulShellModuleRoute, or AliasRoute
Register and access dependencies in Modugo modules using GetIt via the binds() method
Contexto completo do projeto Modugo — lib Flutter de roteamento modular e injeção de dependência sobre GoRouter + GetIt. Carregue esta skill sempre que for explorar, implementar, especificar ou revisar qualquer coisa no repositório.