go_router_guards 0.1.0+1 copy "go_router_guards: ^0.1.0+1" to clipboard
go_router_guards: ^0.1.0+1 copied to clipboard

A flexible and extensible guard system for Go Router that allows you to chain multiple guards together for route protection.

Changelog #

0.1.0+1 - 2025-07-28 #

Added #

  • RouteGuard Interface: Abstract base class for creating custom route guards

    • Supports both synchronous and asynchronous guard operations
    • Returns null to allow access or a redirect path to deny access
    • Full type safety with Go Router integration
  • GuardChain System: Chainable guard system for executing multiple guards in sequence

    • Add guards individually with add() method
    • Add multiple guards at once with addAll() method
    • Execute guards in order with early termination on first redirect
    • Chain management with clear(), length, isEmpty, and isNotEmpty properties
  • GuardedRoute Mixin: Mixin for applying guards to GoRouteData classes

    • Easy integration with existing Go Router type-safe routes
    • Override guards getter to define route protection
    • Automatic guard execution on route access
  • Type-Safe Navigation: Full integration with Go Router's type-safe routing

    • Use Route().location for type-safe redirects
    • Compile-time safety for route paths
    • Integration with @TypedGoRoute annotations
  • Comprehensive Testing: Complete test coverage for all components

    • Unit tests for RouteGuard interface
    • GuardChain execution and management tests
    • GuardedRoute integration tests
    • Mock implementations for testing
  • Documentation: Extensive documentation and examples

    • Quick start guide with type-safe route examples
    • Best practices for guard implementation
    • Migration guide from manual guards
    • Testing examples for guards and routes

Features #

  • Flexible Guard System: Create guards for authentication, permissions, app state, or any custom conditions
  • Chainable Guards: Combine multiple guards in a single route for complex protection logic
  • Performance Optimized: Guards execute in order with early termination for optimal performance
  • Error Handling: Robust error handling with graceful fallbacks
  • Extensible Architecture: Easy to extend and customize for specific use cases

Technical Details #

  • SDK Requirements: Flutter >=3.19.0, Dart SDK ^3.5.0
  • Dependencies: go_router ^16.0.0
  • Development Tools: build_runner, go_router_builder, mocktail, very_good_analysis
  • License: MIT License
4
likes
150
points
6
downloads

Documentation

API reference

Publisher

verified publisheraquiles.dev

Weekly Downloads

A flexible and extensible guard system for Go Router that allows you to chain multiple guards together for route protection.

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

flutter, go_router

More

Packages that depend on go_router_guards