of static method
- BuildContext context
Fetches the Zeta instance from the provided context
.
It ensures that the context has access to the Zeta theming information. Throws a FlutterError if the Zeta is not found in the widget tree.
Implementation
static Zeta of(BuildContext context) {
final defaults = context.dependOnInheritedWidgetOfExactType<Zeta>();
if (defaults != null) {
return defaults;
} else {
throw FlutterError.fromParts(
[
ErrorDescription('Unable to find Zeta in the widget tree.'),
ErrorHint(
'Ensure that the context passed to Zeta.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.',
),
],
);
}
}