of static method

ZetaProviderState of(
  1. BuildContext context
)

Retrieves the ZetaProviderState from the provided context.

Implementation

static ZetaProviderState of(BuildContext context) {
  final zetaState = context.findAncestorStateOfType<ZetaProviderState>();
  if (zetaState != null) {
    return zetaState;
  } else {
    throw FlutterError.fromParts(
      [
        ErrorDescription('Unable to find ZetaProviderState in the widget tree.'),
        ErrorHint(
          'Ensure that the context passed to ZetaProvider.of() is a descendant of a ZetaProvider widget. This usually means that ZetaProviderState should be an ancestor of the widget which uses this context.',
        ),
        ErrorSpacer(),
        ErrorDescription('The widget for the context used was:'),
        DiagnosticsProperty<Widget>('widget', context.widget, showName: false),
        ErrorSpacer(),
        ErrorHint(
          'If you recently changed the type of that widget, or the widget tree, ensure the ZetaProvider widget is still an ancestor.',
        ),
      ],
    );
  }
}