of static method
The closest instance of this class that encloses the given context.
{@tool snippet} Typical usage is as follows:
WizardController controller = DefaultWizardController.of(context);
{@end-tool}
Implementation
static WizardController of(
BuildContext context,
) {
final _WizardControllerScope? scope =
context.dependOnInheritedWidgetOfExactType<_WizardControllerScope>();
final controller = scope?.controller;
if (controller == null) {
// TODO: improve
throw Exception(
"No wizard controller can be found within the widget tree. Please make sure your widget is wrapped with a DefaultWizardController widget.",
);
}
return controller;
}