of static method

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

Access Beamer's routerDelegate.

Giving true to root gets the root beamer if the closest beamer is nested under another beamer.

Implementation

static BeamerDelegate of(BuildContext context, {bool root = false}) {
  try {
    final delegate = Router.of(context).routerDelegate as BeamerDelegate;
    return root ? delegate.root : delegate;
  } 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;
  }
}