of static method
- BuildContext context
The closest instance of DrawerController that encloses the given context.
If no instance is found, this method will assert in debug mode and throw an exception in release mode.
Calling this method will create a dependency on the closest
DrawerController in the context
.
Implementation
static DrawerController of(BuildContext context) {
final DrawerController? controller = maybeOf(context);
assert(() {
if (controller == null) {
throw FlutterError(
'DrawerController.of() was called with a context that does not '
'contain a DrawerController widget.\n'
'No DrawerController widget ancestor could be found starting from '
'the context that was passed to DrawerController.of(). This can '
'happen because you are using a widget that looks for a DrawerController '
'ancestor, but no such ancestor exists.\n'
'The context used was:\n'
' $context',
);
}
return true;
}());
return controller!;
}