maybeOf method Null safety

CupertinoUserInterfaceLevelData? maybeOf(
  1. BuildContext context
)

The data from the closest instance of this class that encloses the given context, if there is one.

Returns null if no CupertinoUserInterfaceLevel 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.

See also:

Implementation

static CupertinoUserInterfaceLevelData? maybeOf(BuildContext context) {
  assert(context != null);
  final CupertinoUserInterfaceLevel? query = context.dependOnInheritedWidgetOfExactType<CupertinoUserInterfaceLevel>();
  if (query != null) {
    return query._data;
  }
  return null;
}