DefaultNavigationPlugin constructor

DefaultNavigationPlugin({
  1. bool urlReflectsImperativeAPIs = false,
  2. GoRouterRedirect? redirect,
  3. int maxRetainedBranches = defaultMaxRetainedBranches,
  4. OnEnter? onEnter,
  5. int redirectLimit = 5,
  6. Listenable? refreshListenable,
  7. GoExceptionHandler? onException,
  8. GoRouterWidgetBuilder? errorBuilder,
  9. GoRouterPageBuilder? errorPageBuilder,
  10. Codec<Object?, Object?>? extraCodec,
  11. String? restorationScopeId,
  12. bool requestFocus = true,
  13. bool routerNeglect = false,
  14. bool overridePlatformDefaultLocation = false,
  15. RouterUrlStyle? urlStyle,
})

Creates the GoRouter-based navigation plugin.

  • redirect: a global redirect, run before every feature redirect.
  • urlStyle: hash or path URLs on the web. Applied immediately, so create the plugin before runApp.
  • urlReflectsImperativeAPIs: whether push and friends update the browser URL.

Implementation

DefaultNavigationPlugin({
  final bool urlReflectsImperativeAPIs = false,
  this.redirect,
  super.maxRetainedBranches,
  this.onEnter,
  this.redirectLimit = 5,
  this.refreshListenable,
  this.onException,
  this.errorBuilder,
  this.errorPageBuilder,
  this.extraCodec,
  this.restorationScopeId,
  this.requestFocus = true,
  this.routerNeglect = false,
  this.overridePlatformDefaultLocation = false,
  RouterUrlStyle? urlStyle,
}) : super(
       name: 'vyuh.plugin.navigation.default',
       title: 'Default Navigation Plugin (GoRouter)',
     ) {
  if (urlReflectsImperativeAPIs) {
    enableURLReflectsImperativeAPIs();
  }

  switch (urlStyle) {
    case RouterUrlStyle.path:
      usePathStrategy();
    case RouterUrlStyle.hash:
      useHashStrategy();
    case null:
      break;
  }
}