of static method

DBRouterDelegate of(
  1. BuildContext context, {
  2. bool root = false,
})

Get the nearest DBRouterDelegate from the provided context.

Implementation

static DBRouterDelegate of(final BuildContext context, {bool root = false}) {
  final NavigatorState navigator = Navigator.of(context, rootNavigator: root);

  final RouterDelegate<dynamic> delegate =
      Router.of(navigator.context).routerDelegate;

  if (delegate is DBRouterDelegate) {
    return delegate;
  } else {
    throw const DBRouterDelegateNotFoundException();
  }
}