of static method

ViewPort of(
  1. BuildContext context
)

Implementation

static ViewPort of(BuildContext context) {
  final ViewPortWidget? widget =
      context.dependOnInheritedWidgetOfExactType<ViewPortWidget>();
  if (widget == null) {
    throw FlutterError.fromParts(<DiagnosticsNode>[
      ErrorSummary(
          'ViewPortWidget.of() called with a context that does not contain a '
          'ViewPortWidget.'),
      ErrorDescription('''
No ViewPortWidget ancestor could be found starting from the context that was
passed to ViewPortWidget.of(). This most probably happens because the parents
chain of the widget that requested invoked ViewPortWidget.of() does not have a
ViewPortWidget instance as a part of it's tree.'''),
      context.describeElement('The context used was')
    ]);
  } else {
    return widget.factory.create(context);
  }
}