of static method

GgRouterCore of(
  1. BuildContext context, {
  2. bool rootRouter = false,
})

Returns the next GgRouterState instance in the widget tree.

Implementation

static GgRouterCore of(
  BuildContext context, {
  bool rootRouter = false,
}) {
  GgRouterCore? core = context.findAncestorWidgetOfExactType<GgRouterCore>();

  if (rootRouter) {
    final rootRouterState =
        context.findRootAncestorStateOfType<GgRouterState>()!;

    core = rootRouterState.rootRouterCore;
  }

  assert(() {
    if (core == null) {
      throw FlutterError(noGgRouterDelegateFoundError);
    }
    return true;
  }());
  return core!;
}