of static method

The master detail flow proxy from the closest instance of this class that encloses the given context.

Typical usage is as follows:

MasterDetailFlowWidget.of(context).openDetailPage(arguments);

Implementation

static MasterDetailFlowWidgetProxy of(BuildContext context) {
  _PageOpener? pageOpener =
      context.findAncestorStateOfType<MasterDetailScaffoldWidgetState>();
  pageOpener ??=
      context.findAncestorStateOfType<MasterDetailFlowWidgetState>();
  assert(() {
    if (pageOpener == null) {
      throw FlutterError(
        'Master Detail operation requested with a context that does not include a Master Detail '
        'Flow.\nThe context used to open a detail page from the Master Detail Flow must be '
        'that of a widget that is a descendant of a Master Detail Flow widget.',
      );
    }
    return true;
  }());
  return MasterDetailFlowWidgetProxy._(pageOpener!);
}