maybeOf static method

DatePickerThemeData? 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 DatePickerTheme is in scope. Prefer using DatePickerTheme.of in situations where a DatePickerThemeData is expected to be non-null.

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

Typical usage is as follows:

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

See also:

Implementation

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