of method

CupertinoUserInterfaceLevelData of (
  1. BuildContext context,
  2. {bool nullOk: false}
)

The data from the closest instance of this class that encloses the given context.

You can use this function to query the user interface elevation level within the given BuildContext. When that information changes, your widget will be scheduled to be rebuilt, keeping your widget up-to-date.

Implementation

static CupertinoUserInterfaceLevelData of(BuildContext context, { bool nullOk = false }) {
  assert(context != null);
  assert(nullOk != null);
  final CupertinoUserInterfaceLevel query = context.dependOnInheritedWidgetOfExactType<CupertinoUserInterfaceLevel>();
  if (query != null)
    return query._data;
  if (nullOk)
    return null;
  throw FlutterError(
    'CupertinoUserInterfaceLevel.of() called with a context that does not contain a CupertinoUserInterfaceLevel.\n'
    'No CupertinoUserInterfaceLevel ancestor could be found starting from the context that was passed '
    'to CupertinoUserInterfaceLevel.of(). This can happen because you do not have a WidgetsApp or '
    'MaterialApp widget (those widgets introduce a CupertinoUserInterfaceLevel), or it can happen '
    'if the context you use comes from a widget above those widgets.\n'
    'The context used was:\n'
    '  $context'
  );
}