Skip to content

(experimental) A general Navigator 2.0 router created for production use. Features full state restoration, browser go back/go forward support and built-in deep linking.

License

Notifications You must be signed in to change notification settings

Zekfad/k_router

Repository files navigation

K Router experimental

A general Navigator 2.0 router created for production use.

Here's the list of features this implementation provides:

  • Imperative API - this router API consists of imperative calls that mutate tree-like navigation stack.
  • Deep linking - supports custom logic for deep-links: you can push new location or ignore deep-link for example to trigger custom side effects. This is a useful feature to prevent errors with incompatible URIs, since users can have outdated version of your app.
  • Full restoration support - this router is designed for state restoration support from the start, even parallel navigation chains are preserved. Every location's page is provided with restoration ID removing clashes and allowing for a seamless restoration of duplicate routes.
  • Tree navigation stack - this router supports not only normal routes, but also shell (nested navigation) and parallel multi shell pages (multiple nested navigators on a single screen). You can also nest them.
  • Page modification - this router allows you to replace Page object and re-render route with new data, such as updating URI or name for CupertinoPage.
  • Browser history support - because this router requires restoration it allows for a better handling of browser back and forward action.

Currently this router provides the bare minimum required for it's proper operation. Which creates following limitations:

  • You have to bring your own Uri-to-Location mapping mechanism if you need it. (tip think about radix tree/prefix tree).

  • Since router allows restoration to basically any previous state, this creates a vector for route guards bypass, so this router DOES NOT provide any guards for locations.

    You're advised to create your own abstraction for checking location's required permissions AND implementing same check inside of location's UI. This is needed for case when location guard mechanism depends on external state and that state is no longer valid after restoration. (For example: user leaves app at profile settings page, then revokes app session from the browser, after restoration app will be at profile page of no longer authorized user, so you should to handle that)

  • Currently this router DOES NOT support predictive back with shell or multi locations because of Flutter#152323.

About

(experimental) A general Navigator 2.0 router created for production use. Features full state restoration, browser go back/go forward support and built-in deep linking.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages