of static method

GetRootState of(
  1. BuildContext context
)

Implementation

static GetRootState of(BuildContext context) {
  // Handles the case where the input context is a navigator element.
  GetRootState? root;
  if (context is StatefulElement && context.state is GetRootState) {
    root = context.state as GetRootState;
  }
  root = context.findRootAncestorStateOfType<GetRootState>() ?? root;
  assert(() {
    if (root == null) {
      throw FlutterError(
        'GetRoot operation requested with a context that does not include a GetRoot.\n'
        'The context used must be that of a '
        'widget that is a descendant of a GetRoot widget.',
      );
    }
    return true;
  }());
  return root!;
}