maybeOf static method

DropdownMenuThemeData? maybeOf(
  1. BuildContext context
)

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

Use this function if you want to allow situations where no DropdownMenuTheme is in scope. Prefer using DropdownMenuTheme.of in situations where a DropdownMenuThemeData is expected to be non-null.

If there is no DropdownMenuTheme in scope, then this function will return null.

Typical usage is as follows:

DropdownMenuThemeData? theme = DropdownMenuTheme.maybeOf(context);
if (theme == null) {
  // Do something else instead.
}

See also:

Implementation

static DropdownMenuThemeData? maybeOf(BuildContext context) {
  return context.dependOnInheritedWidgetOfExactType<DropdownMenuTheme>()?.data;
}