maybeOf<T extends Object> static method

T? maybeOf<T extends Object>(
  1. BuildContext context, {
  2. bool listen = false,
})

Obtains the nearest Scope

If not found searches in GlobalScope.read

Return null if T not exist.

Implementation

static T? maybeOf<T extends Object>(
  BuildContext context, {
  bool listen = false,
}) {
  T? value;
  value = InheritedScope.of<T>(context, listen) ?? GlobalScope.read<T>();
  return value;
}