of static method

BeamerDelegate<BeamState> of(
  1. BuildContext context, {
  2. bool root = false,
})

Access Beamer's routerDelegate.

Implementation

static BeamerDelegate of(BuildContext context, {bool root = false}) {
  BeamerDelegate _delegate;
  try {
    _delegate = Router.of(context).routerDelegate as BeamerDelegate;
  } catch (e) {
    assert(BeamerProvider.of(context) != null,
        'There was no Router nor BeamerProvider in current context. If using MaterialApp.builder, wrap the MaterialApp.router in BeamerProvider to which you pass the same routerDelegate as to MaterialApp.router.');
    return BeamerProvider.of(context)!.routerDelegate;
  }
  if (root) {
    return _delegate.root;
  }
  return _delegate;
}